From 9467c4682c796351fca09b78fdccb4b24a54a9de Mon Sep 17 00:00:00 2001 From: Jason Rhinelander Date: Tue, 1 Sep 2020 15:10:21 -0300 Subject: [PATCH] Add C string bt_value ctor --- lokimq/bt_value.h | 1 + tests/test_bt.cpp | 3 +++ 2 files changed, 4 insertions(+) diff --git a/lokimq/bt_value.h b/lokimq/bt_value.h index 2719ec8..7cf6269 100644 --- a/lokimq/bt_value.h +++ b/lokimq/bt_value.h @@ -106,6 +106,7 @@ struct bt_value : bt_variant { template , std::enable_if_t && !detail::is_tuple, int> = 0> bt_value(T&& v) : bt_variant{std::forward(v)} {} + bt_value(const char* s) : bt_value{std::string_view{s}} {} }; } diff --git a/tests/test_bt.cpp b/tests/test_bt.cpp index 2f1a877..60dfafe 100644 --- a/tests/test_bt.cpp +++ b/tests/test_bt.cpp @@ -90,6 +90,9 @@ TEST_CASE("bt_value serialization", "[bt][serialization][bt_value]") { std::string x_ = bt_serialize(dna); REQUIRE( bt_serialize(dna) == "i42e" ); + bt_value foo{"foo"}; + REQUIRE( bt_serialize(foo) == "3:foo" ); + bt_value ibig{-8'000'000'000'000'000'000LL}; bt_value ubig{10'000'000'000'000'000'000ULL}; int16_t ismall = -123;