aboutsummaryrefslogtreecommitdiff
path: root/src/univalue
diff options
context:
space:
mode:
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");