Changeset View
Changeset View
Standalone View
Standalone View
src/test/util_tests.cpp
Show First 20 Lines • Show All 1,846 Lines • ▼ Show 20 Lines | BOOST_CHECK_EQUAL( | ||||
std::string("/Test:0.9.99/")); | std::string("/Test:0.9.99/")); | ||||
BOOST_CHECK_EQUAL(FormatSubVersion("Test", 99900, comments), | BOOST_CHECK_EQUAL(FormatSubVersion("Test", 99900, comments), | ||||
std::string("/Test:0.9.99(comment1)/")); | std::string("/Test:0.9.99(comment1)/")); | ||||
BOOST_CHECK_EQUAL( | BOOST_CHECK_EQUAL( | ||||
FormatSubVersion("Test", 99900, comments2), | FormatSubVersion("Test", 99900, comments2), | ||||
std::string("/Test:0.9.99(comment1; Comment2; .,_?@-; )/")); | std::string("/Test:0.9.99(comment1; Comment2; .,_?@-; )/")); | ||||
} | } | ||||
BOOST_AUTO_TEST_CASE(test_FormatSubVersionUserAgent) { | |||||
std::vector<std::string> comments; | |||||
comments.push_back(std::string("comment1")); | |||||
std::vector<std::string> comments2; | |||||
comments2.push_back(std::string("comment1")); | |||||
// Semicolon is discouraged but not forbidden by BIP-0014 | |||||
comments2.push_back(SanitizeString( | |||||
std::string("Comment2; .,_?@-; !\"#$%&'()*+/<=>[]\\^`{|}~"), | |||||
SAFE_CHARS_UA_COMMENT)); | |||||
BOOST_CHECK_EQUAL( | |||||
FormatSubVersionUserAgent("Test:0.9.99", std::vector<std::string>()), | |||||
std::string("/Test:0.9.99/")); | |||||
BOOST_CHECK_EQUAL(FormatSubVersionUserAgent("Test:0.9.99", comments), | |||||
std::string("/Test:0.9.99(comment1)/")); | |||||
BOOST_CHECK_EQUAL( | |||||
FormatSubVersionUserAgent("Test:0.9.99", comments2), | |||||
std::string("/Test:0.9.99(comment1; Comment2; .,_?@-; )/")); | |||||
} | |||||
BOOST_AUTO_TEST_CASE(test_ParseFixedPoint) { | BOOST_AUTO_TEST_CASE(test_ParseFixedPoint) { | ||||
int64_t amount = 0; | int64_t amount = 0; | ||||
BOOST_CHECK(ParseFixedPoint("0", 8, &amount)); | BOOST_CHECK(ParseFixedPoint("0", 8, &amount)); | ||||
BOOST_CHECK_EQUAL(amount, 0LL); | BOOST_CHECK_EQUAL(amount, 0LL); | ||||
BOOST_CHECK(ParseFixedPoint("1", 8, &amount)); | BOOST_CHECK(ParseFixedPoint("1", 8, &amount)); | ||||
BOOST_CHECK_EQUAL(amount, 100000000LL); | BOOST_CHECK_EQUAL(amount, 100000000LL); | ||||
BOOST_CHECK(ParseFixedPoint("0.0", 8, &amount)); | BOOST_CHECK(ParseFixedPoint("0.0", 8, &amount)); | ||||
BOOST_CHECK_EQUAL(amount, 0LL); | BOOST_CHECK_EQUAL(amount, 0LL); | ||||
▲ Show 20 Lines • Show All 642 Lines • Show Last 20 Lines |