fix msvc, by doubling parenthesis on catch assertions
This commit is contained in:
parent
3d405c6883
commit
7e750ec1fa
@ -38,86 +38,86 @@ TEST_CASE("lexer class")
|
|||||||
{
|
{
|
||||||
SECTION("structural characters")
|
SECTION("structural characters")
|
||||||
{
|
{
|
||||||
CHECK(json::lexer(reinterpret_cast<const json::lexer::lexer_char_t*>("["),
|
CHECK((json::lexer(reinterpret_cast<const json::lexer::lexer_char_t*>("["),
|
||||||
1).scan() == json::lexer::token_type::begin_array);
|
1).scan() == json::lexer::token_type::begin_array));
|
||||||
CHECK(json::lexer(reinterpret_cast<const json::lexer::lexer_char_t*>("]"),
|
CHECK((json::lexer(reinterpret_cast<const json::lexer::lexer_char_t*>("]"),
|
||||||
1).scan() == json::lexer::token_type::end_array);
|
1).scan() == json::lexer::token_type::end_array));
|
||||||
CHECK(json::lexer(reinterpret_cast<const json::lexer::lexer_char_t*>("{"),
|
CHECK((json::lexer(reinterpret_cast<const json::lexer::lexer_char_t*>("{"),
|
||||||
1).scan() == json::lexer::token_type::begin_object);
|
1).scan() == json::lexer::token_type::begin_object));
|
||||||
CHECK(json::lexer(reinterpret_cast<const json::lexer::lexer_char_t*>("}"),
|
CHECK((json::lexer(reinterpret_cast<const json::lexer::lexer_char_t*>("}"),
|
||||||
1).scan() == json::lexer::token_type::end_object);
|
1).scan() == json::lexer::token_type::end_object));
|
||||||
CHECK(json::lexer(reinterpret_cast<const json::lexer::lexer_char_t*>(","),
|
CHECK((json::lexer(reinterpret_cast<const json::lexer::lexer_char_t*>(","),
|
||||||
1).scan() == json::lexer::token_type::value_separator);
|
1).scan() == json::lexer::token_type::value_separator));
|
||||||
CHECK(json::lexer(reinterpret_cast<const json::lexer::lexer_char_t*>(":"),
|
CHECK((json::lexer(reinterpret_cast<const json::lexer::lexer_char_t*>(":"),
|
||||||
1).scan() == json::lexer::token_type::name_separator);
|
1).scan() == json::lexer::token_type::name_separator));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("literal names")
|
SECTION("literal names")
|
||||||
{
|
{
|
||||||
CHECK(json::lexer(reinterpret_cast<const json::lexer::lexer_char_t*>("null"),
|
CHECK((json::lexer(reinterpret_cast<const json::lexer::lexer_char_t*>("null"),
|
||||||
4).scan() == json::lexer::token_type::literal_null);
|
4).scan() == json::lexer::token_type::literal_null));
|
||||||
CHECK(json::lexer(reinterpret_cast<const json::lexer::lexer_char_t*>("true"),
|
CHECK((json::lexer(reinterpret_cast<const json::lexer::lexer_char_t*>("true"),
|
||||||
4).scan() == json::lexer::token_type::literal_true);
|
4).scan() == json::lexer::token_type::literal_true));
|
||||||
CHECK(json::lexer(reinterpret_cast<const json::lexer::lexer_char_t*>("false"),
|
CHECK((json::lexer(reinterpret_cast<const json::lexer::lexer_char_t*>("false"),
|
||||||
5).scan() == json::lexer::token_type::literal_false);
|
5).scan() == json::lexer::token_type::literal_false));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("numbers")
|
SECTION("numbers")
|
||||||
{
|
{
|
||||||
CHECK(json::lexer(reinterpret_cast<const json::lexer::lexer_char_t*>("0"),
|
CHECK((json::lexer(reinterpret_cast<const json::lexer::lexer_char_t*>("0"),
|
||||||
1).scan() == json::lexer::token_type::value_number);
|
1).scan() == json::lexer::token_type::value_number));
|
||||||
CHECK(json::lexer(reinterpret_cast<const json::lexer::lexer_char_t*>("1"),
|
CHECK((json::lexer(reinterpret_cast<const json::lexer::lexer_char_t*>("1"),
|
||||||
1).scan() == json::lexer::token_type::value_number);
|
1).scan() == json::lexer::token_type::value_number));
|
||||||
CHECK(json::lexer(reinterpret_cast<const json::lexer::lexer_char_t*>("2"),
|
CHECK((json::lexer(reinterpret_cast<const json::lexer::lexer_char_t*>("2"),
|
||||||
1).scan() == json::lexer::token_type::value_number);
|
1).scan() == json::lexer::token_type::value_number));
|
||||||
CHECK(json::lexer(reinterpret_cast<const json::lexer::lexer_char_t*>("3"),
|
CHECK((json::lexer(reinterpret_cast<const json::lexer::lexer_char_t*>("3"),
|
||||||
1).scan() == json::lexer::token_type::value_number);
|
1).scan() == json::lexer::token_type::value_number));
|
||||||
CHECK(json::lexer(reinterpret_cast<const json::lexer::lexer_char_t*>("4"),
|
CHECK((json::lexer(reinterpret_cast<const json::lexer::lexer_char_t*>("4"),
|
||||||
1).scan() == json::lexer::token_type::value_number);
|
1).scan() == json::lexer::token_type::value_number));
|
||||||
CHECK(json::lexer(reinterpret_cast<const json::lexer::lexer_char_t*>("5"),
|
CHECK((json::lexer(reinterpret_cast<const json::lexer::lexer_char_t*>("5"),
|
||||||
1).scan() == json::lexer::token_type::value_number);
|
1).scan() == json::lexer::token_type::value_number));
|
||||||
CHECK(json::lexer(reinterpret_cast<const json::lexer::lexer_char_t*>("6"),
|
CHECK((json::lexer(reinterpret_cast<const json::lexer::lexer_char_t*>("6"),
|
||||||
1).scan() == json::lexer::token_type::value_number);
|
1).scan() == json::lexer::token_type::value_number));
|
||||||
CHECK(json::lexer(reinterpret_cast<const json::lexer::lexer_char_t*>("7"),
|
CHECK((json::lexer(reinterpret_cast<const json::lexer::lexer_char_t*>("7"),
|
||||||
1).scan() == json::lexer::token_type::value_number);
|
1).scan() == json::lexer::token_type::value_number));
|
||||||
CHECK(json::lexer(reinterpret_cast<const json::lexer::lexer_char_t*>("8"),
|
CHECK((json::lexer(reinterpret_cast<const json::lexer::lexer_char_t*>("8"),
|
||||||
1).scan() == json::lexer::token_type::value_number);
|
1).scan() == json::lexer::token_type::value_number));
|
||||||
CHECK(json::lexer(reinterpret_cast<const json::lexer::lexer_char_t*>("9"),
|
CHECK((json::lexer(reinterpret_cast<const json::lexer::lexer_char_t*>("9"),
|
||||||
1).scan() == json::lexer::token_type::value_number);
|
1).scan() == json::lexer::token_type::value_number));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("whitespace")
|
SECTION("whitespace")
|
||||||
{
|
{
|
||||||
// result is end_of_input, because not token is following
|
// result is end_of_input, because not token is following
|
||||||
CHECK(json::lexer(reinterpret_cast<const json::lexer::lexer_char_t*>(" "),
|
CHECK((json::lexer(reinterpret_cast<const json::lexer::lexer_char_t*>(" "),
|
||||||
1).scan() == json::lexer::token_type::end_of_input);
|
1).scan() == json::lexer::token_type::end_of_input));
|
||||||
CHECK(json::lexer(reinterpret_cast<const json::lexer::lexer_char_t*>("\t"),
|
CHECK((json::lexer(reinterpret_cast<const json::lexer::lexer_char_t*>("\t"),
|
||||||
1).scan() == json::lexer::token_type::end_of_input);
|
1).scan() == json::lexer::token_type::end_of_input));
|
||||||
CHECK(json::lexer(reinterpret_cast<const json::lexer::lexer_char_t*>("\n"),
|
CHECK((json::lexer(reinterpret_cast<const json::lexer::lexer_char_t*>("\n"),
|
||||||
1).scan() == json::lexer::token_type::end_of_input);
|
1).scan() == json::lexer::token_type::end_of_input));
|
||||||
CHECK(json::lexer(reinterpret_cast<const json::lexer::lexer_char_t*>("\r"),
|
CHECK((json::lexer(reinterpret_cast<const json::lexer::lexer_char_t*>("\r"),
|
||||||
1).scan() == json::lexer::token_type::end_of_input);
|
1).scan() == json::lexer::token_type::end_of_input));
|
||||||
CHECK(json::lexer(reinterpret_cast<const json::lexer::lexer_char_t*>(" \t\n\r\n\t "),
|
CHECK((json::lexer(reinterpret_cast<const json::lexer::lexer_char_t*>(" \t\n\r\n\t "),
|
||||||
7).scan() == json::lexer::token_type::end_of_input);
|
7).scan() == json::lexer::token_type::end_of_input));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("token_type_name")
|
SECTION("token_type_name")
|
||||||
{
|
{
|
||||||
CHECK(json::lexer::token_type_name(json::lexer::token_type::uninitialized) == "<uninitialized>");
|
CHECK((json::lexer::token_type_name(json::lexer::token_type::uninitialized) == "<uninitialized>"));
|
||||||
CHECK(json::lexer::token_type_name(json::lexer::token_type::literal_true) == "true literal");
|
CHECK((json::lexer::token_type_name(json::lexer::token_type::literal_true) == "true literal"));
|
||||||
CHECK(json::lexer::token_type_name(json::lexer::token_type::literal_false) == "false literal");
|
CHECK((json::lexer::token_type_name(json::lexer::token_type::literal_false) == "false literal"));
|
||||||
CHECK(json::lexer::token_type_name(json::lexer::token_type::literal_null) == "null literal");
|
CHECK((json::lexer::token_type_name(json::lexer::token_type::literal_null) == "null literal"));
|
||||||
CHECK(json::lexer::token_type_name(json::lexer::token_type::value_string) == "string literal");
|
CHECK((json::lexer::token_type_name(json::lexer::token_type::value_string) == "string literal"));
|
||||||
CHECK(json::lexer::token_type_name(json::lexer::token_type::value_number) == "number literal");
|
CHECK((json::lexer::token_type_name(json::lexer::token_type::value_number) == "number literal"));
|
||||||
CHECK(json::lexer::token_type_name(json::lexer::token_type::begin_array) == "'['");
|
CHECK((json::lexer::token_type_name(json::lexer::token_type::begin_array) == "'['"));
|
||||||
CHECK(json::lexer::token_type_name(json::lexer::token_type::begin_object) == "'{'");
|
CHECK((json::lexer::token_type_name(json::lexer::token_type::begin_object) == "'{'"));
|
||||||
CHECK(json::lexer::token_type_name(json::lexer::token_type::end_array) == "']'");
|
CHECK((json::lexer::token_type_name(json::lexer::token_type::end_array) == "']'"));
|
||||||
CHECK(json::lexer::token_type_name(json::lexer::token_type::end_object) == "'}'");
|
CHECK((json::lexer::token_type_name(json::lexer::token_type::end_object) == "'}'"));
|
||||||
CHECK(json::lexer::token_type_name(json::lexer::token_type::name_separator) == "':'");
|
CHECK((json::lexer::token_type_name(json::lexer::token_type::name_separator) == "':'"));
|
||||||
CHECK(json::lexer::token_type_name(json::lexer::token_type::value_separator) == "','");
|
CHECK((json::lexer::token_type_name(json::lexer::token_type::value_separator) == "','"));
|
||||||
CHECK(json::lexer::token_type_name(json::lexer::token_type::parse_error) == "<parse error>");
|
CHECK((json::lexer::token_type_name(json::lexer::token_type::parse_error) == "<parse error>"));
|
||||||
CHECK(json::lexer::token_type_name(json::lexer::token_type::end_of_input) == "end of input");
|
CHECK((json::lexer::token_type_name(json::lexer::token_type::end_of_input) == "end of input"));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("parse errors on first character")
|
SECTION("parse errors on first character")
|
||||||
@ -150,7 +150,7 @@ TEST_CASE("lexer class")
|
|||||||
case ('8'):
|
case ('8'):
|
||||||
case ('9'):
|
case ('9'):
|
||||||
{
|
{
|
||||||
CHECK(res != json::lexer::token_type::parse_error);
|
CHECK((res != json::lexer::token_type::parse_error));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,14 +160,14 @@ TEST_CASE("lexer class")
|
|||||||
case ('\n'):
|
case ('\n'):
|
||||||
case ('\r'):
|
case ('\r'):
|
||||||
{
|
{
|
||||||
CHECK(res == json::lexer::token_type::end_of_input);
|
CHECK((res == json::lexer::token_type::end_of_input));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// anything else is not expected
|
// anything else is not expected
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
CHECK(res == json::lexer::token_type::parse_error);
|
CHECK((res == json::lexer::token_type::parse_error));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user