summaryrefslogtreecommitdiffstats
path: root/src/jaegertracing/opentracing-cpp/test/value_test.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:45:59 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:45:59 +0000
commit19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch)
tree42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /src/jaegertracing/opentracing-cpp/test/value_test.cpp
parentInitial commit. (diff)
downloadceph-upstream.tar.xz
ceph-upstream.zip
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/jaegertracing/opentracing-cpp/test/value_test.cpp')
-rw-r--r--src/jaegertracing/opentracing-cpp/test/value_test.cpp62
1 files changed, 62 insertions, 0 deletions
diff --git a/src/jaegertracing/opentracing-cpp/test/value_test.cpp b/src/jaegertracing/opentracing-cpp/test/value_test.cpp
new file mode 100644
index 000000000..cd84165d0
--- /dev/null
+++ b/src/jaegertracing/opentracing-cpp/test/value_test.cpp
@@ -0,0 +1,62 @@
+#include <opentracing/value.h>
+using namespace opentracing;
+
+#define CATCH_CONFIG_MAIN
+#include <opentracing/catch2/catch.hpp>
+
+TEST_CASE("Value") {
+ SECTION("Signed integers get converted to int64_t.") {
+ Value v1(123);
+ CHECK(v1.is<int64_t>());
+
+ Value v2(static_cast<short>(123));
+ CHECK(v2.is<int64_t>());
+ }
+
+ SECTION("Unsigned integers get converted to uint64_t.") {
+ Value v1(123u);
+ CHECK(v1.is<uint64_t>());
+
+ Value v2(static_cast<unsigned short>(123));
+ CHECK(v2.is<uint64_t>());
+ }
+
+ SECTION("Bool values are deduced as bool.") {
+ Value v1(true);
+ // Workaround for "disabled expansion of recursive macro" warning.
+ const auto is_bool = v1.is<bool>();
+ CHECK(is_bool);
+ }
+
+ SECTION("Floating point numbers are converted to double.") {
+ Value v1(1.0);
+ CHECK(v1.is<double>());
+ Value v2(1.0f);
+ CHECK(v2.is<double>());
+ }
+
+ SECTION("std::string values are deduced as std::string.") {
+ Value v1(std::string("abc"));
+ CHECK(v1.is<std::string>());
+ }
+
+ SECTION("c-string values are deduced as c-strings.") {
+ Value v1("abc");
+ CHECK(v1.is<const char*>());
+ }
+
+ SECTION("Complex values are permitted.") {
+ Value v1(Values{Value(1), Value(2)});
+ (void)v1;
+
+ Value v2(Dictionary{{"abc", Value(123)}});
+ (void)v2;
+ }
+
+ SECTION("Value types can be compared for equality.") {
+ Value v1{1}, v2{2}, v3{1.0};
+ CHECK(v1 == v1);
+ CHECK(v1 != v2);
+ CHECK(v1 != v3);
+ }
+}