isoltest: Fixes parsing and printing strings with *basic* escape sequences in it.

We explicitly did not implement a fully conformant ANSI escape sequence
parser but only what is needed for now.
This commit is contained in:
Christian Parpart
2019-07-22 11:32:17 +02:00
parent 535553b523
commit 58d8243921
6 changed files with 136 additions and 17 deletions
@@ -310,6 +310,50 @@ BOOST_AUTO_TEST_CASE(call_arguments_bool)
);
}
BOOST_AUTO_TEST_CASE(scanner_hex_values)
{
char const* source = R"(
// f(uint256): "\x20\x00\xFf" ->
)";
auto const calls = parse(source);
BOOST_REQUIRE_EQUAL(calls.size(), 1);
testFunctionCall(calls.at(0), Mode::SingleLine, "f(uint256)", false, fmt::encodeArgs(string("\x20\x00\xff", 3)));
}
BOOST_AUTO_TEST_CASE(scanner_hex_values_invalid1)
{
char const* source = R"(
// f(uint256): "\x" ->
)";
BOOST_REQUIRE_THROW(parse(source), langutil::Error);
}
BOOST_AUTO_TEST_CASE(scanner_hex_values_invalid2)
{
char const* source = R"(
// f(uint256): "\x1" ->
)";
auto const calls = parse(source);
BOOST_REQUIRE_EQUAL(calls.size(), 1);
testFunctionCall(calls.at(0), Mode::SingleLine, "f(uint256)", false, fmt::encodeArgs(string("\x1", 1)));
}
BOOST_AUTO_TEST_CASE(scanner_hex_values_invalid3)
{
char const* source = R"(
// f(uint256): "\xZ" ->
)";
BOOST_REQUIRE_THROW(parse(source), langutil::Error);
}
BOOST_AUTO_TEST_CASE(scanner_hex_values_invalid4)
{
char const* source = R"(
// f(uint256): "\xZZ" ->
)";
BOOST_REQUIRE_THROW(parse(source), langutil::Error);
}
BOOST_AUTO_TEST_CASE(call_arguments_hex_string)
{
char const* source = R"(