🔨 fixing last failing test cases

This commit is contained in:
Niels Lohmann 2017-03-28 17:00:03 +02:00
parent b0c47abd88
commit bbb6bd9de5
No known key found for this signature in database
GPG key ID: 7F3CEA63AE251B69
3 changed files with 37 additions and 45 deletions

View file

@ -306,9 +306,9 @@ TEST_CASE("parser class")
CHECK_THROWS_AS(json::parser("+0").parse(), json::parse_error);
CHECK_THROWS_WITH(json::parser("01").parse(),
"[json.exception.parse_error.101] parse error at 2: syntax error - unexpected '01'");
"[json.exception.parse_error.101] parse error at 2: syntax error - unexpected number literal; expected end of input");
CHECK_THROWS_WITH(json::parser("-01").parse(),
"[json.exception.parse_error.101] parse error at 3: syntax error - unexpected '-01'");
"[json.exception.parse_error.101] parse error at 3: syntax error - unexpected number literal; expected end of input");
CHECK_THROWS_WITH(json::parser("--1").parse(),
"[json.exception.parse_error.101] parse error at 2: syntax error - invalid number; expected digit after '-'; last read '--'");
CHECK_THROWS_WITH(json::parser("1.").parse(),
@ -318,7 +318,7 @@ TEST_CASE("parser class")
CHECK_THROWS_WITH(json::parser("1E-").parse(),
"[json.exception.parse_error.101] parse error at 4: syntax error - invalid number; expected digit after exponent sign; last read '1E-'");
CHECK_THROWS_WITH(json::parser("1.E1").parse(),
"[json.exception.parse_error.101] parse error at 2: syntax error - unexpected '.'; expected end of input");
"[json.exception.parse_error.101] parse error at 3: syntax error - invalid number; expected digit after '.'; last read '1.E'");
CHECK_THROWS_WITH(json::parser("-1E").parse(),
"[json.exception.parse_error.101] parse error at 4: syntax error - invalid number; expected '+', '-', or digit after exponent; last read '-1E'");
CHECK_THROWS_WITH(json::parser("-0E#").parse(),
@ -326,19 +326,19 @@ TEST_CASE("parser class")
CHECK_THROWS_WITH(json::parser("-0E-#").parse(),
"[json.exception.parse_error.101] parse error at 5: syntax error - invalid number; expected digit after exponent sign; last read '-0E-#'");
CHECK_THROWS_WITH(json::parser("-0#").parse(),
"[json.exception.parse_error.101] parse error at 3: syntax error - unexpected '#'; expected end of input");
"[json.exception.parse_error.101] parse error at 3: syntax error - invalid literal; last read: '-0#'; expected end of input");
CHECK_THROWS_WITH(json::parser("-0.0:").parse(),
"[json.exception.parse_error.101] parse error at 5: syntax error - unexpected ':'; expected end of input");
CHECK_THROWS_WITH(json::parser("-0.0Z").parse(),
"[json.exception.parse_error.101] parse error at 5: syntax error - unexpected 'Z'; expected end of input");
"[json.exception.parse_error.101] parse error at 5: syntax error - invalid literal; last read: '-0.0Z'; expected end of input");
CHECK_THROWS_WITH(json::parser("-0E123:").parse(),
"[json.exception.parse_error.101] parse error at 7: syntax error - unexpected ':'; expected end of input");
CHECK_THROWS_WITH(json::parser("-0e0-:").parse(),
"[json.exception.parse_error.101] parse error at 5: syntax error - unexpected '-'; expected end of input");
"[json.exception.parse_error.101] parse error at 6: syntax error - invalid number; expected digit after '-'; last read: '-:'; expected end of input");
CHECK_THROWS_WITH(json::parser("-0e-:").parse(),
"[json.exception.parse_error.101] parse error at 5: syntax error - invalid number; expected digit after exponent sign; last read '-0e-:'");
CHECK_THROWS_WITH(json::parser("-0f").parse(),
"[json.exception.parse_error.101] parse error at 3: syntax error - unexpected 'f'; expected end of input");
"[json.exception.parse_error.101] parse error at 4: syntax error - invalid literal; expected 'false'; last read: '-0f'; expected end of input");
}
}
}

View file

@ -77,9 +77,8 @@ TEST_CASE("compliance tests from json.org")
})
{
CAPTURE(filename);
json j;
std::ifstream f(filename);
CHECK_THROWS_AS(j << f, json::parse_error);
CHECK_THROWS_AS(json::parse(f), json::parse_error);
}
}
@ -93,9 +92,8 @@ TEST_CASE("compliance tests from json.org")
})
{
CAPTURE(filename);
json j;
std::ifstream f(filename);
CHECK_NOTHROW(j << f);
CHECK_NOTHROW(json::parse(f));
}
}
}
@ -320,7 +318,7 @@ TEST_CASE("test suite from json-test-suite")
// strings in a JSON array
std::ifstream f("test/data/json_testsuite/sample.json");
json j;
CHECK_NOTHROW(j << f);
CHECK_NOTHROW(j = json::parse(f));
// the array has 3 elements
CHECK(j.size() == 3);
@ -334,36 +332,31 @@ TEST_CASE("json.org examples")
SECTION("1.json")
{
std::ifstream f("test/data/json.org/1.json");
json j;
CHECK_NOTHROW(j << f);
CHECK_NOTHROW(json::parse(f));
}
SECTION("2.json")
{
std::ifstream f("test/data/json.org/2.json");
json j;
CHECK_NOTHROW(j << f);
CHECK_NOTHROW(json::parse(f));
}
SECTION("3.json")
{
std::ifstream f("test/data/json.org/3.json");
json j;
CHECK_NOTHROW(j << f);
CHECK_NOTHROW(json::parse(f));
}
SECTION("4.json")
{
std::ifstream f("test/data/json.org/4.json");
json j;
CHECK_NOTHROW(j << f);
CHECK_NOTHROW(json::parse(f));
}
SECTION("5.json")
{
std::ifstream f("test/data/json.org/5.json");
json j;
CHECK_NOTHROW(j << f);
CHECK_NOTHROW(json::parse(f));
}
}
@ -545,8 +538,7 @@ TEST_CASE("nst's JSONTestSuite")
{
CAPTURE(filename);
std::ifstream f(filename);
json j;
CHECK_NOTHROW(j << f);
CHECK_NOTHROW(json::parse(f));
}
}
@ -754,8 +746,7 @@ TEST_CASE("nst's JSONTestSuite")
{
CAPTURE(filename);
std::ifstream f(filename);
json j;
CHECK_THROWS_AS(j << f, json::parse_error);
CHECK_THROWS_AS(json::parse(f), json::parse_error);
}
}
@ -777,8 +768,7 @@ TEST_CASE("nst's JSONTestSuite")
{
CAPTURE(filename);
std::ifstream f(filename);
json j;
CHECK_NOTHROW(j << f);
CHECK_NOTHROW(json::parse(f));
}
}
@ -797,8 +787,7 @@ TEST_CASE("nst's JSONTestSuite")
{
CAPTURE(filename);
std::ifstream f(filename);
json j;
CHECK_THROWS_AS(j << f, json::out_of_range);
CHECK_THROWS_AS(json::parse(f), json::out_of_range);
}
}
@ -824,8 +813,7 @@ TEST_CASE("nst's JSONTestSuite")
{
CAPTURE(filename);
std::ifstream f(filename);
json j;
CHECK_THROWS_AS(j << f, json::parse_error);
CHECK_THROWS_AS(json::parse(f), json::parse_error);
}
}
}
@ -851,8 +839,7 @@ TEST_CASE("Big List of Naughty Strings")
SECTION("parsing blns.json")
{
std::ifstream f("test/data/big-list-of-naughty-strings/blns.json");
json j;
CHECK_NOTHROW(j << f);
CHECK_NOTHROW(json::parse(f));
}
// check if parsed strings roundtrip