From b196c6498d22e47bb9d0da0153068ec54eac7956 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 11:44:33 +0200 Subject: Adding upstream version 1.6.0. Signed-off-by: Daniel Baumann --- test/value_test.cpp | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 test/value_test.cpp (limited to 'test/value_test.cpp') diff --git a/test/value_test.cpp b/test/value_test.cpp new file mode 100644 index 0000000..cd84165 --- /dev/null +++ b/test/value_test.cpp @@ -0,0 +1,62 @@ +#include +using namespace opentracing; + +#define CATCH_CONFIG_MAIN +#include + +TEST_CASE("Value") { + SECTION("Signed integers get converted to int64_t.") { + Value v1(123); + CHECK(v1.is()); + + Value v2(static_cast(123)); + CHECK(v2.is()); + } + + SECTION("Unsigned integers get converted to uint64_t.") { + Value v1(123u); + CHECK(v1.is()); + + Value v2(static_cast(123)); + CHECK(v2.is()); + } + + SECTION("Bool values are deduced as bool.") { + Value v1(true); + // Workaround for "disabled expansion of recursive macro" warning. + const auto is_bool = v1.is(); + CHECK(is_bool); + } + + SECTION("Floating point numbers are converted to double.") { + Value v1(1.0); + CHECK(v1.is()); + Value v2(1.0f); + CHECK(v2.is()); + } + + SECTION("std::string values are deduced as std::string.") { + Value v1(std::string("abc")); + CHECK(v1.is()); + } + + SECTION("c-string values are deduced as c-strings.") { + Value v1("abc"); + CHECK(v1.is()); + } + + 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); + } +} -- cgit v1.2.3