mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-24 07:21:22 +02:00
univalue: string_view test
This commit is contained in:
parent
1111c7e3f1
commit
fa09525751
@ -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");
|
||||
|
Loading…
x
Reference in New Issue
Block a user