aboutsummaryrefslogtreecommitdiff
path: root/src/univalue
diff options
context:
space:
mode:
authorMacroFake <falke.marco@gmail.com>2022-07-14 13:41:44 +0200
committerMacroFake <falke.marco@gmail.com>2022-11-07 09:41:19 +0100
commitfa095257511e53d7a593c6714724aafb484e6b6f (patch)
tree7d1911756c84c588336d9dc49b51a868bd0a6078 /src/univalue
parent1111c7e3f1f5c550f62016d71ccc518aafd97acf (diff)
univalue: string_view test
Diffstat (limited to 'src/univalue')
-rw-r--r--src/univalue/test/object.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/univalue/test/object.cpp b/src/univalue/test/object.cpp
index 94d7343ff3..65e82543e4 100644
--- a/src/univalue/test/object.cpp
+++ b/src/univalue/test/object.cpp
@@ -11,6 +11,7 @@
#include <memory>
#include <stdexcept>
#include <string>
+#include <string_view>
#include <vector>
#define BOOST_CHECK(expr) assert(expr)
@@ -160,6 +161,14 @@ void univalue_set()
BOOST_CHECK(v.isStr());
BOOST_CHECK_EQUAL(v.getValStr(), "zum");
+ {
+ std::string_view sv{"ab\0c", 4};
+ UniValue j{sv};
+ BOOST_CHECK(j.isStr());
+ BOOST_CHECK_EQUAL(j.getValStr(), sv);
+ BOOST_CHECK_EQUAL(j.write(), "\"ab\\u0000c\"");
+ }
+
v.setFloat(-1.01);
BOOST_CHECK(v.isNum());
BOOST_CHECK_EQUAL(v.getValStr(), "-1.01");