diff options
Diffstat (limited to 'vespalib/src/tests/trace/trace_serialization.cpp')
-rw-r--r-- | vespalib/src/tests/trace/trace_serialization.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/vespalib/src/tests/trace/trace_serialization.cpp b/vespalib/src/tests/trace/trace_serialization.cpp index c176ca9fcf9..9ba6cdb512b 100644 --- a/vespalib/src/tests/trace/trace_serialization.cpp +++ b/vespalib/src/tests/trace/trace_serialization.cpp @@ -1,11 +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("trace_test"); #include <vespa/vespalib/testkit/test_kit.h> #include <vespa/vespalib/trace/tracenode.h> #include <vespa/vespalib/trace/slime_trace_serializer.h> #include <vespa/vespalib/trace/slime_trace_deserializer.h> +#include <vespa/log/log.h> +LOG_SETUP("trace_test"); + using namespace vespalib; using namespace vespalib::slime; @@ -20,10 +21,14 @@ TEST("that a single trace node is serialized") { EXPECT_FALSE(i["payload"].valid()); } +constexpr system_time zero_system_time(duration::zero()); +constexpr system_time as_ms(long ms) { return system_time(std::chrono::milliseconds(ms)); } + + TEST("that a trace node with children is serialized") { TraceNode node; - node.addChild("foo", 1234); - node.addChild("bar", 1235); + node.addChild("foo", as_ms(1234)); + node.addChild("bar", as_ms(1235)); Slime slime; SlimeTraceSerializer serializer(slime.setObject()); node.accept(serializer); @@ -47,7 +52,7 @@ TEST("that an empty root trace node can be deserialized") { SlimeTraceDeserializer deserializer(root); TraceNode node(deserializer.deserialize()); EXPECT_FALSE(node.hasNote()); - EXPECT_EQUAL(0, node.getTimestamp()); + EXPECT_EQUAL(zero_system_time, node.getTimestamp()); } @@ -58,7 +63,7 @@ TEST("that a single trace node can be deserialized") { root.setString("payload", "hello"); SlimeTraceDeserializer deserializer(root); TraceNode node(deserializer.deserialize()); - EXPECT_EQUAL(1234, node.getTimestamp()); + EXPECT_EQUAL(as_ms(1234), node.getTimestamp()); EXPECT_TRUE(node.hasNote()); EXPECT_EQUAL("hello", node.getNote()); } @@ -95,7 +100,7 @@ TEST("that a trace node with children can be deserialized") { TEST("test serialization and deserialization") { TraceNode root; - root.addChild("foo", 45); + root.addChild("foo", as_ms(45)); root.addChild("bar"); root.addChild(TraceNode()); Slime slime; |