23 #include <boost/test/unit_test.hpp> 35 h64 a(
"0xbaadf00ddeadbeef");
36 u64 b(
"0xffff0000bbbaaaa");
37 uint64_t
c = 38990234243;
38 bytes d = {0xff, 0x0, 0xef, 0xbc};
48 bytes a = {0xff, 0xaa, 0xbb, 0xcc};
49 bytes b = {0x03, 0x89, 0x90, 0x23, 0x42, 0x43};
62 bytes c = {0xff, 0xaa, 0xbb, 0xcc};
72 bytes c = {0xff, 0xaa, 0xbb, 0xcc};
78 bytes a = {0xff, 0xaa, 0x00, 0x00, 0x00};
88 bytes a = {0x00, 0x00, 0x00, 0xff, 0xaa};
99 h256 a(
"0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
103 h256 c(
"0x4173636969436861726163746572730000000000000000000000000000000000");
109 h256 a(
"0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
110 BOOST_CHECK(a == jsToFixed<32>(
"0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"));
111 h256 b(
"0x000000000000000000000000000000000000000000000000000000740c54b42f");
123 BOOST_CHECK(
u256(
"983298932490823474234") == jsToInt<32>(
"983298932490823474234"));
124 BOOST_CHECK(
u256(
"983298932490823474234") == jsToInt<32>(
"0x354e03915c00571c3a"));
126 BOOST_CHECK(
u128(
"228273101986715476958866839113050921216") == jsToInt<16>(
"0xabbbccddeeff11223344556677889900"));
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
BOOST_AUTO_TEST_CASE(test_toJS)
std::hash for asio::adress
bytes unpadded(bytes _b)
Removing all trailing '0'. Returns empty array if input contains only '0' char.
std::string toJS(FixedHash< S > const &_h)
string fromRaw(h256 _n)
Convert h256 into user-readable string (by directly using std::string constructor). If it can't be interpreted as an ASCII string, empty string is returned.
std::vector< byte > bytes
Fixed-size raw-byte array container type, with an API optimised for storing hashes.
boost::multiprecision::number< boost::multiprecision::cpp_int_backend< 256, 256, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void >> u256
bytes paddedRight(bytes _b, unsigned _l)
Add '0' on, or remove items from, the back of _b until it is of length _l.
bytes jsToBytes(string const &_s, OnFailed _f)
boost::multiprecision::number< boost::multiprecision::cpp_int_backend< 64, 64, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void >> u64
boost::multiprecision::number< boost::multiprecision::cpp_int_backend< 128, 128, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void >> u128
#define BOOST_FIXTURE_TEST_SUITE(a, b)
bytes padded(bytes _b, unsigned _l)
Add '0' on, or remove items from, the front of _b until it is of length _l.
#define BOOST_AUTO_TEST_SUITE_END()
boost::multiprecision::number< boost::multiprecision::cpp_int_backend< N *8, N *8, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void > > jsToInt(std::string const &_s)
Convert a string representation of a number to an int String can be a normal decimal number...
bytes unpadLeft(bytes _b)
Remove all 0 byte on the head of _s.
u256 jsToU256(std::string const &_s)
Helper functions to work with json::spirit and test files.
#define BOOST_CHECK(expr)