Skip to content

Commit 519eede

Browse files
committed
fix univalue json parse tests
1 parent c7fbbc7 commit 519eede

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/test/rpc_tests.cpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -143,20 +143,23 @@ BOOST_AUTO_TEST_CASE(rpc_parse_monetary_values)
143143

144144
BOOST_AUTO_TEST_CASE(json_parse_errors)
145145
{
146-
Value value;
146+
UniValue value;
147147
// Valid
148-
BOOST_CHECK_EQUAL(read_string(std::string("1.0"), value), true);
148+
BOOST_CHECK_EQUAL(value.read(std::string("1.0")), false);
149+
BOOST_CHECK_EQUAL(value.read(std::string("[1.0]")), true);
149150
// Valid, with trailing whitespace
150-
BOOST_CHECK_EQUAL(read_string(std::string("1.0 "), value), true);
151+
BOOST_CHECK_EQUAL(value.read(std::string("1.0 ")), false);
152+
BOOST_CHECK_EQUAL(value.read(std::string("[1.0 ] ")), true);
151153
// Invalid, initial garbage
152-
BOOST_CHECK_EQUAL(read_string(std::string("[1.0"), value), false);
153-
BOOST_CHECK_EQUAL(read_string(std::string("a1.0"), value), false);
154+
BOOST_CHECK_EQUAL(value.read(std::string("[1.0")), false);
155+
BOOST_CHECK_EQUAL(value.read(std::string("[a1.0]")), false);
156+
BOOST_CHECK_EQUAL(value.read(std::string("[\"a1.0\"]")), true);
154157
// Invalid, trailing garbage
155-
BOOST_CHECK_EQUAL(read_string(std::string("1.0sds"), value), false);
156-
BOOST_CHECK_EQUAL(read_string(std::string("1.0]"), value), false);
158+
BOOST_CHECK_EQUAL(value.read(std::string("1.0sds")), false);
159+
BOOST_CHECK_EQUAL(value.read(std::string("1.0]")), false);
157160
// BTC addresses should fail parsing
158-
BOOST_CHECK_EQUAL(read_string(std::string("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"), value), false);
159-
BOOST_CHECK_EQUAL(read_string(std::string("3J98t1WpEZ73CNmQviecrnyiWrnqRhWNL"), value), false);
161+
BOOST_CHECK_EQUAL(value.read(std::string("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W")), false);
162+
BOOST_CHECK_EQUAL(value.read(std::string("3J98t1WpEZ73CNmQviecrnyiWrnqRhWNL")), false);
160163
}
161164

162165
BOOST_AUTO_TEST_CASE(rpc_boostasiotocnetaddr)

0 commit comments

Comments
 (0)