more test cases
This commit is contained in:
parent
4361c4d03f
commit
40a0773e43
1 changed files with 76 additions and 12 deletions
|
@ -3564,6 +3564,19 @@ TEST_CASE("modifiers")
|
|||
}
|
||||
|
||||
SECTION("to object")
|
||||
{
|
||||
SECTION("null")
|
||||
{
|
||||
json j;
|
||||
j.push_back(json::object_t::value_type({"one", 1}));
|
||||
j.push_back(json::object_t::value_type({"two", 2}));
|
||||
CHECK(j.type() == json::value_t::object);
|
||||
CHECK(j.size() == 2);
|
||||
CHECK(j["one"] == json(1));
|
||||
CHECK(j["two"] == json(2));
|
||||
}
|
||||
|
||||
SECTION("object")
|
||||
{
|
||||
json j(json::value_t::object);
|
||||
j.push_back(json::object_t::value_type({"one", 1}));
|
||||
|
@ -3572,6 +3585,14 @@ TEST_CASE("modifiers")
|
|||
CHECK(j["one"] == json(1));
|
||||
CHECK(j["two"] == json(2));
|
||||
}
|
||||
|
||||
SECTION("other type")
|
||||
{
|
||||
json j = 1;
|
||||
json k("Hello");
|
||||
CHECK_THROWS_AS(j.push_back(json::object_t::value_type({"one", 1})), std::runtime_error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("operator+=")
|
||||
|
@ -3635,6 +3656,19 @@ TEST_CASE("modifiers")
|
|||
}
|
||||
|
||||
SECTION("to object")
|
||||
{
|
||||
SECTION("null")
|
||||
{
|
||||
json j;
|
||||
j += json::object_t::value_type({"one", 1});
|
||||
j += json::object_t::value_type({"two", 2});
|
||||
CHECK(j.type() == json::value_t::object);
|
||||
CHECK(j.size() == 2);
|
||||
CHECK(j["one"] == json(1));
|
||||
CHECK(j["two"] == json(2));
|
||||
}
|
||||
|
||||
SECTION("object")
|
||||
{
|
||||
json j(json::value_t::object);
|
||||
j += json::object_t::value_type({"one", 1});
|
||||
|
@ -3643,6 +3677,14 @@ TEST_CASE("modifiers")
|
|||
CHECK(j["one"] == json(1));
|
||||
CHECK(j["two"] == json(2));
|
||||
}
|
||||
|
||||
SECTION("other type")
|
||||
{
|
||||
json j = 1;
|
||||
json k("Hello");
|
||||
CHECK_THROWS_AS(j += json::object_t::value_type({"one", 1}), std::runtime_error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("swap()")
|
||||
|
@ -5176,5 +5218,27 @@ TEST_CASE("parser class")
|
|||
|
||||
// unexpected end of string
|
||||
CHECK_THROWS_AS(json::parser("\"").parse(), std::invalid_argument);
|
||||
CHECK_THROWS_AS(json::parser("\\").parse(), std::invalid_argument);
|
||||
CHECK_THROWS_AS(json::parser("\\u").parse(), std::invalid_argument);
|
||||
CHECK_THROWS_AS(json::parser("\\u0").parse(), std::invalid_argument);
|
||||
CHECK_THROWS_AS(json::parser("\\u01").parse(), std::invalid_argument);
|
||||
CHECK_THROWS_AS(json::parser("\\u012").parse(), std::invalid_argument);
|
||||
|
||||
// invalid escapes
|
||||
CHECK_THROWS_AS(json::parser("\\!").parse(), std::invalid_argument);
|
||||
CHECK_THROWS_AS(json::parser("\\#").parse(), std::invalid_argument);
|
||||
CHECK_THROWS_AS(json::parser("\\[").parse(), std::invalid_argument);
|
||||
CHECK_THROWS_AS(json::parser("\\]").parse(), std::invalid_argument);
|
||||
CHECK_THROWS_AS(json::parser("\\.").parse(), std::invalid_argument);
|
||||
CHECK_THROWS_AS(json::parser("\\0").parse(), std::invalid_argument);
|
||||
CHECK_THROWS_AS(json::parser("\\a").parse(), std::invalid_argument);
|
||||
CHECK_THROWS_AS(json::parser("\\c").parse(), std::invalid_argument);
|
||||
CHECK_THROWS_AS(json::parser("\\e").parse(), std::invalid_argument);
|
||||
CHECK_THROWS_AS(json::parser("\\g").parse(), std::invalid_argument);
|
||||
CHECK_THROWS_AS(json::parser("\\m").parse(), std::invalid_argument);
|
||||
CHECK_THROWS_AS(json::parser("\\o").parse(), std::invalid_argument);
|
||||
CHECK_THROWS_AS(json::parser("\\q").parse(), std::invalid_argument);
|
||||
CHECK_THROWS_AS(json::parser("\\s").parse(), std::invalid_argument);
|
||||
CHECK_THROWS_AS(json::parser("\\v").parse(), std::invalid_argument);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue