@@ -279,6 +279,34 @@ BOOST_AUTO_TEST_CASE( operator_with_self )
279
279
BOOST_CHECK (v == UintToArith256 (uint256S (" 0" )));
280
280
}
281
281
282
+ BOOST_AUTO_TEST_CASE (parse)
283
+ {
284
+ {
285
+ std::string s_12{" 0000000000000000000000000000000000000000000000000000000000000012" };
286
+ BOOST_CHECK_EQUAL (uint256S (" 12\0 " ).GetHex (), s_12);
287
+ BOOST_CHECK_EQUAL (uint256S (std::string{" 12\0 " , 3 }).GetHex (), s_12);
288
+ BOOST_CHECK_EQUAL (uint256S (" 0x12" ).GetHex (), s_12);
289
+ BOOST_CHECK_EQUAL (uint256S (" 0x12" ).GetHex (), s_12);
290
+ BOOST_CHECK_EQUAL (uint256S (" 12" ).GetHex (), s_12);
291
+ }
292
+ {
293
+ std::string s_1{uint256::ONE.GetHex ()};
294
+ BOOST_CHECK_EQUAL (uint256S (" 1\0 " ).GetHex (), s_1);
295
+ BOOST_CHECK_EQUAL (uint256S (std::string{" 1\0 " , 2 }).GetHex (), s_1);
296
+ BOOST_CHECK_EQUAL (uint256S (" 0x1" ).GetHex (), s_1);
297
+ BOOST_CHECK_EQUAL (uint256S (" 0x1" ).GetHex (), s_1);
298
+ BOOST_CHECK_EQUAL (uint256S (" 1" ).GetHex (), s_1);
299
+ }
300
+ {
301
+ std::string s_0{uint256::ZERO.GetHex ()};
302
+ BOOST_CHECK_EQUAL (uint256S (" \0 " ).GetHex (), s_0);
303
+ BOOST_CHECK_EQUAL (uint256S (std::string{" \0 " , 1 }).GetHex (), s_0);
304
+ BOOST_CHECK_EQUAL (uint256S (" 0x" ).GetHex (), s_0);
305
+ BOOST_CHECK_EQUAL (uint256S (" 0x" ).GetHex (), s_0);
306
+ BOOST_CHECK_EQUAL (uint256S (" " ).GetHex (), s_0);
307
+ }
308
+ }
309
+
282
310
BOOST_AUTO_TEST_CASE ( check_ONE )
283
311
{
284
312
uint256 one = uint256S (" 0000000000000000000000000000000000000000000000000000000000000001" );
0 commit comments