aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/tests/engine
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2019-03-05 10:32:58 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2019-03-05 12:17:02 +0000
commitd138c1667dfaf921d2fea1990f7964df1a4a48f8 (patch)
tree8226b41daa04d0909e402d2915def97880839bed /searchlib/src/tests/engine
parentd9a1b8be930da47e9c7b42ab44eecd29b385c170 (diff)
Add a simple Trace Object wrapping the slime.
Diffstat (limited to 'searchlib/src/tests/engine')
-rw-r--r--searchlib/src/tests/engine/searchapi/searchapi_test.cpp78
1 files changed, 49 insertions, 29 deletions
diff --git a/searchlib/src/tests/engine/searchapi/searchapi_test.cpp b/searchlib/src/tests/engine/searchapi/searchapi_test.cpp
index a517890620c..f06ce5c188c 100644
--- a/searchlib/src/tests/engine/searchapi/searchapi_test.cpp
+++ b/searchlib/src/tests/engine/searchapi/searchapi_test.cpp
@@ -1,10 +1,12 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/log/log.h>
-LOG_SETUP("searchapi_test");
+
#include <vespa/vespalib/testkit/testapp.h>
#include <vespa/searchlib/common/packets.h>
#include <vespa/searchlib/engine/searchapi.h>
#include <vespa/searchlib/engine/packetconverter.h>
+#include <vespa/vespalib/data/slime/slime.h>
+#include <vespa/log/log.h>
+LOG_SETUP("searchapi_test");
using namespace search::engine;
using namespace search::fs4transport;
@@ -28,18 +30,8 @@ template <typename T> void copyPacket(T &src, T &dst) {
} // namespace <unnamed>
-class Test : public vespalib::TestApp
-{
-public:
- void propertyNames();
- void convertToRequest();
- void convertFromReply();
- int Main() override;
-};
-
-void
-Test::propertyNames()
-{
+
+TEST("propertyNames") {
EXPECT_EQUAL(search::MapNames::RANK, "rank");
EXPECT_EQUAL(search::MapNames::FEATURE, "feature");
EXPECT_EQUAL(search::MapNames::HIGHLIGHTTERMS, "highlightterms");
@@ -47,9 +39,7 @@ Test::propertyNames()
EXPECT_EQUAL(search::MapNames::CACHES, "caches");
}
-void
-Test::convertToRequest()
-{
+TEST("convertToReques") {
FS4Packet_QUERYX src;
src._offset = 2u;
src._maxhits = 3u;
@@ -116,9 +106,7 @@ Test::convertToRequest()
}
}
-void
-Test::convertFromReply()
-{
+TEST("convertFromReply") {
SearchReply src;
src.offset = 1u;
src.totalHitCount = 2u;
@@ -240,14 +228,46 @@ Test::convertFromReply()
}
}
-int
-Test::Main()
-{
- TEST_INIT("searchapi_test");
- propertyNames();
- convertToRequest();
- convertFromReply();
- TEST_DONE();
+void verify(vespalib::stringref expected, const vespalib::Slime & slime) {
+ vespalib::Slime expectedSlime;
+ vespalib::slime::JsonFormat::decode(expected, expectedSlime);
+ EXPECT_EQUAL(expectedSlime, slime);
+}
+
+TEST("verify trace") {
+ Trace t(7);
+ verify("{"
+ " traces: ["
+ " ],"
+ " creation_time: 7"
+ "}",
+ t.getRoot());
+
+ t.createCursor("tag_a");
+ verify("{"
+ " traces: ["
+ " {"
+ " tag: 'tag_a'"
+ " }"
+ " ],"
+ " creation_time: 7"
+ "}",
+ t.getRoot());
+ Trace::Cursor & tagB = t.createCursor("tag_b");
+ tagB.setLong("long", 19);
+ verify("{"
+ " traces: ["
+ " {"
+ " tag: 'tag_a'"
+ " },"
+ " {"
+ " tag: 'tag_b',"
+ " long: 19"
+ " }"
+ " ],"
+ " creation_time: 7"
+ "}",
+ t.getRoot());
}
-TEST_APPHOOK(Test);
+TEST_MAIN() { TEST_RUN_ALL(); } \ No newline at end of file