| 12 | |
| 13 | BOOST_AUTO_TEST_SUITE(script_parse_tests) |
| 14 | BOOST_AUTO_TEST_CASE(parse_script) |
| 15 | { |
| 16 | const std::vector<std::pair<std::string,std::string>> IN_OUT{ |
| 17 | // {IN: script string , OUT: hex string } |
| 18 | {"", ""}, |
| 19 | {"0", "00"}, |
| 20 | {"1", "51"}, |
| 21 | {"2", "52"}, |
| 22 | {"3", "53"}, |
| 23 | {"4", "54"}, |
| 24 | {"5", "55"}, |
| 25 | {"6", "56"}, |
| 26 | {"7", "57"}, |
| 27 | {"8", "58"}, |
| 28 | {"9", "59"}, |
| 29 | {"10", "5a"}, |
| 30 | {"11", "5b"}, |
| 31 | {"12", "5c"}, |
| 32 | {"13", "5d"}, |
| 33 | {"14", "5e"}, |
| 34 | {"15", "5f"}, |
| 35 | {"16", "60"}, |
| 36 | {"17", "0111"}, |
| 37 | {"-9", "0189"}, |
| 38 | {"0x17", "17"}, |
| 39 | {"'17'", "023137"}, |
| 40 | {"ELSE", "67"}, |
| 41 | {"NOP10", "b9"}, |
| 42 | }; |
| 43 | std::string all_in; |
| 44 | std::string all_out; |
| 45 | for (const auto& [in, out] : IN_OUT) { |
| 46 | BOOST_CHECK_EQUAL(HexStr(ParseScript(in)), out); |
| 47 | all_in += " " + in + " "; |
| 48 | all_out += out; |
| 49 | } |
| 50 | BOOST_CHECK_EQUAL(HexStr(ParseScript(all_in)), all_out); |
| 51 | |
| 52 | BOOST_CHECK_EXCEPTION(ParseScript("11111111111111111111"), std::runtime_error, HasReason("script parse error: decimal numeric value only allowed in the range -0xFFFFFFFF...0xFFFFFFFF")); |
| 53 | BOOST_CHECK_EXCEPTION(ParseScript("11111111111"), std::runtime_error, HasReason("script parse error: decimal numeric value only allowed in the range -0xFFFFFFFF...0xFFFFFFFF")); |
| 54 | // BOOST_CHECK_EXCEPTION(ParseScript("OP_CHECKSIGADD"), std::runtime_error, HasReason("script parse error: unknown opcode")); // ELEMENTS |
| 55 | } |
| 56 | BOOST_AUTO_TEST_SUITE_END() |
nothing calls this directly
no test coverage detected