Modify test cases

This commit is contained in:
junyoungjo 2018-12-18 23:09:14 +09:00
parent 894d32b2aa
commit 671cd7babf
2 changed files with 0 additions and 66 deletions

View File

@ -246,18 +246,6 @@ TEST_CASE("constructors")
CHECK(j == j_reference);
}
SECTION("std::pair")
{
std::pair<float, std::string> p{1.0f, "string"};
json j(p);
CHECK(j.type() == json::value_t::array);
CHECK(j.get<decltype(p)>() == p);
REQUIRE(j.size() == 2);
CHECK(j[0] == std::get<0>(p));
CHECK(j[1] == std::get<1>(p));
}
SECTION("std::pair with discarded values")
{
json j{1, 2.0, "string"};

View File

@ -1282,60 +1282,6 @@ TEST_CASE("value conversion")
j5.get<std::unordered_set<std::string>>();
}
SECTION("std::map (array of pairs)")
{
std::map<int, int> m{{0, 1}, {1, 2}, {2, 3}};
json j6 = m;
auto m2 = j6.get<std::map<int, int>>();
CHECK(m == m2);
json j7 = {0, 1, 2, 3};
json j8 = 2;
CHECK_THROWS_AS((j7.get<std::map<int, int>>()), json::type_error&);
CHECK_THROWS_AS((j8.get<std::map<int, int>>()), json::type_error&);
CHECK_THROWS_WITH((j7.get<std::map<int, int>>()),
"[json.exception.type_error.302] type must be array, "
"but is number");
CHECK_THROWS_WITH((j8.get<std::map<int, int>>()),
"[json.exception.type_error.302] type must be array, "
"but is number");
SECTION("superfluous entries")
{
json j9 = {{0, 1, 2}, {1, 2, 3}, {2, 3, 4}};
m2 = j9.get<std::map<int, int>>();
CHECK(m == m2);
}
}
SECTION("std::unordered_map (array of pairs)")
{
std::unordered_map<int, int> m{{0, 1}, {1, 2}, {2, 3}};
json j6 = m;
auto m2 = j6.get<std::unordered_map<int, int>>();
CHECK(m == m2);
json j7 = {0, 1, 2, 3};
json j8 = 2;
CHECK_THROWS_AS((j7.get<std::unordered_map<int, int>>()), json::type_error&);
CHECK_THROWS_AS((j8.get<std::unordered_map<int, int>>()), json::type_error&);
CHECK_THROWS_WITH((j7.get<std::unordered_map<int, int>>()),
"[json.exception.type_error.302] type must be array, "
"but is number");
CHECK_THROWS_WITH((j8.get<std::unordered_map<int, int>>()),
"[json.exception.type_error.302] type must be array, "
"but is number");
SECTION("superfluous entries")
{
json j9{{0, 1, 2}, {1, 2, 3}, {2, 3, 4}};
m2 = j9.get<std::unordered_map<int, int>>();
CHECK(m == m2);
}
}
SECTION("exception in case of a non-object type")
{
CHECK_THROWS_AS((json().get<std::list<int>>()), json::type_error&);