Skip to content

Commit

Permalink
fix univalue json parse tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasschnelli committed Jun 4, 2015
1 parent c7fbbc7 commit 519eede
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/test/rpc_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,20 +143,23 @@ BOOST_AUTO_TEST_CASE(rpc_parse_monetary_values)

BOOST_AUTO_TEST_CASE(json_parse_errors)
{
Value value;
UniValue value;
// Valid
BOOST_CHECK_EQUAL(read_string(std::string("1.0"), value), true);
BOOST_CHECK_EQUAL(value.read(std::string("1.0")), false);
BOOST_CHECK_EQUAL(value.read(std::string("[1.0]")), true);
// Valid, with trailing whitespace
BOOST_CHECK_EQUAL(read_string(std::string("1.0 "), value), true);
BOOST_CHECK_EQUAL(value.read(std::string("1.0 ")), false);
BOOST_CHECK_EQUAL(value.read(std::string("[1.0 ] ")), true);
// Invalid, initial garbage
BOOST_CHECK_EQUAL(read_string(std::string("[1.0"), value), false);
BOOST_CHECK_EQUAL(read_string(std::string("a1.0"), value), false);
BOOST_CHECK_EQUAL(value.read(std::string("[1.0")), false);
BOOST_CHECK_EQUAL(value.read(std::string("[a1.0]")), false);
BOOST_CHECK_EQUAL(value.read(std::string("[\"a1.0\"]")), true);
// Invalid, trailing garbage
BOOST_CHECK_EQUAL(read_string(std::string("1.0sds"), value), false);
BOOST_CHECK_EQUAL(read_string(std::string("1.0]"), value), false);
BOOST_CHECK_EQUAL(value.read(std::string("1.0sds")), false);
BOOST_CHECK_EQUAL(value.read(std::string("1.0]")), false);
// BTC addresses should fail parsing
BOOST_CHECK_EQUAL(read_string(std::string("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"), value), false);
BOOST_CHECK_EQUAL(read_string(std::string("3J98t1WpEZ73CNmQviecrnyiWrnqRhWNL"), value), false);
BOOST_CHECK_EQUAL(value.read(std::string("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W")), false);
BOOST_CHECK_EQUAL(value.read(std::string("3J98t1WpEZ73CNmQviecrnyiWrnqRhWNL")), false);
}

BOOST_AUTO_TEST_CASE(rpc_boostasiotocnetaddr)
Expand Down

0 comments on commit 519eede

Please sign in to comment.