Commit bb142d6c authored by Niels's avatar Niels

added test cases

parent 869035a6
...@@ -396,7 +396,7 @@ $ make ...@@ -396,7 +396,7 @@ $ make
$ ./json_unit $ ./json_unit
=============================================================================== ===============================================================================
All tests passed (4673 assertions in 19 test cases) All tests passed (4707 assertions in 20 test cases)
``` ```
For more information, have a look at the file [.travis.yml](https://github.com/nlohmann/json/blob/master/.travis.yml). For more information, have a look at the file [.travis.yml](https://github.com/nlohmann/json/blob/master/.travis.yml).
...@@ -7377,6 +7377,15 @@ TEST_CASE("parser class") ...@@ -7377,6 +7377,15 @@ TEST_CASE("parser class")
// empty string // empty string
CHECK(json::parser("\"\"").parse() == json(json::value_t::string)); CHECK(json::parser("\"\"").parse() == json(json::value_t::string));
SECTION("errors")
{
// error: tab in string
CHECK_THROWS_AS(json::parser("\"\t\"").parse(), std::invalid_argument);
// error: newline in string
CHECK_THROWS_AS(json::parser("\"\n\"").parse(), std::invalid_argument);
CHECK_THROWS_AS(json::parser("\"\r\"").parse(), std::invalid_argument);
}
SECTION("escaped") SECTION("escaped")
{ {
// quotation mark "\"" // quotation mark "\""
...@@ -8524,11 +8533,13 @@ TEST_CASE("regression tests") ...@@ -8524,11 +8533,13 @@ TEST_CASE("regression tests")
SECTION("NAN value") SECTION("NAN value")
{ {
CHECK(json(NAN) == json()); CHECK(json(NAN) == json());
CHECK(json(json::number_float_t(NAN)) == json());
} }
SECTION("infinity") SECTION("infinity")
{ {
CHECK(json(INFINITY) == json()); CHECK(json(INFINITY) == json());
CHECK(json(json::number_float_t(INFINITY)) == json());
} }
} }
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment