Skip to content

Commit fa09525

Browse files
author
MacroFake
committed
univalue: string_view test
1 parent 1111c7e commit fa09525

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/univalue/test/object.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <memory>
1212
#include <stdexcept>
1313
#include <string>
14+
#include <string_view>
1415
#include <vector>
1516

1617
#define BOOST_CHECK(expr) assert(expr)
@@ -160,6 +161,14 @@ void univalue_set()
160161
BOOST_CHECK(v.isStr());
161162
BOOST_CHECK_EQUAL(v.getValStr(), "zum");
162163

164+
{
165+
std::string_view sv{"ab\0c", 4};
166+
UniValue j{sv};
167+
BOOST_CHECK(j.isStr());
168+
BOOST_CHECK_EQUAL(j.getValStr(), sv);
169+
BOOST_CHECK_EQUAL(j.write(), "\"ab\\u0000c\"");
170+
}
171+
163172
v.setFloat(-1.01);
164173
BOOST_CHECK(v.isNum());
165174
BOOST_CHECK_EQUAL(v.getValStr(), "-1.01");

0 commit comments

Comments
 (0)