number test cases

This commit is contained in:
Niels 2015-02-11 11:36:45 +01:00
parent 463c38df60
commit f1bd206994
3 changed files with 31 additions and 7 deletions

View file

@ -3207,7 +3207,6 @@ json_parser_62:
// check if strtod read beyond the end of the lexem // check if strtod read beyond the end of the lexem
if (endptr != m_cursor) if (endptr != m_cursor)
{ {
std::cerr << get_string_value() << std::endl;
return NAN; return NAN;
} }
else else

View file

@ -2566,7 +2566,6 @@ class basic_json
// check if strtod read beyond the end of the lexem // check if strtod read beyond the end of the lexem
if (endptr != m_cursor) if (endptr != m_cursor)
{ {
std::cerr << get_string_value() << std::endl;
return NAN; return NAN;
} }
else else

View file

@ -3799,8 +3799,6 @@ TEST_CASE("lexicographical comparison operators")
{ {
for (size_t j = 0; j < j_values.size(); ++j) for (size_t j = 0; j < j_values.size(); ++j)
{ {
CAPTURE(i);
CAPTURE(j);
// check precomputed values // check precomputed values
CHECK( (j_values[i] < j_values[j]) == expected[i][j] ); CHECK( (j_values[i] < j_values[j]) == expected[i][j] );
} }
@ -4044,9 +4042,6 @@ TEST_CASE("lexer class")
{ {
auto s = std::string(1, c); auto s = std::string(1, c);
CAPTURE(c);
CAPTURE(s);
switch (c) switch (c)
{ {
// characters that are prefixes of reasonable json // characters that are prefixes of reasonable json
@ -4116,5 +4111,36 @@ TEST_CASE("parser class")
{ {
CHECK(json::parser("false").parse() == json(false)); CHECK(json::parser("false").parse() == json(false));
} }
SECTION("number")
{
SECTION("integers")
{
SECTION("without exponent")
{
CHECK(json::parser("-128").parse() == json(-128));
CHECK(json::parser("0").parse() == json(0));
CHECK(json::parser("128").parse() == json(128));
}
SECTION("with exponent")
{
CHECK(json::parser("10000E-4").parse() == json(10000e-4));
CHECK(json::parser("10000E-3").parse() == json(10000e-3));
CHECK(json::parser("10000E-2").parse() == json(10000e-2));
CHECK(json::parser("10000E-1").parse() == json(10000e-1));
CHECK(json::parser("10000E0").parse() == json(10000e0));
CHECK(json::parser("10000E1").parse() == json(10000e1));
CHECK(json::parser("10000E2").parse() == json(10000e2));
CHECK(json::parser("10000E3").parse() == json(10000e3));
CHECK(json::parser("10000E4").parse() == json(10000e4));
}
}
SECTION("invalid numbers")
{
CHECK_THROWS_AS(json::parser("01").parse(), std::invalid_argument);
}
}
} }
} }