1
0
mirror of https://github.com/nlohmann/json synced 2024-11-27 14:20:07 +00:00

more test cases

This commit is contained in:
Niels 2015-02-08 16:14:49 +01:00
parent 441a6f267f
commit d38596793e

View File

@ -197,7 +197,7 @@ TEST_CASE("constructors")
CHECK(j == j_reference); CHECK(j == j_reference);
} }
SECTION("std::array<json>") SECTION("std::array<json, 5>")
{ {
std::array<json, 5> a {{json(1), json(2.2), json(false), json("string"), json()}}; std::array<json, 5> a {{json(1), json(2.2), json(false), json("string"), json()}};
json j(a); json j(a);
@ -1170,7 +1170,7 @@ TEST_CASE("value conversion")
SECTION("json::object_t") SECTION("json::object_t")
{ {
json::object_t o = j.get<std::map<std::string, json>>(); json::object_t o = j.get<json::object_t>();
CHECK(json(o) == j); CHECK(json(o) == j);
} }
@ -1198,4 +1198,40 @@ TEST_CASE("value conversion")
CHECK(json(o) == j); CHECK(json(o) == j);
} }
} }
SECTION("get an array (explicit)")
{
json::array_t a_reference {json(1), json(2.2), json(false), json("string"), json()};
json j(a_reference);
SECTION("json::array_t")
{
json::array_t a = j.get<json::array_t>();
CHECK(json(a) == j);
}
SECTION("std::list<json>")
{
std::list<json> a = j.get<std::list<json>>();
CHECK(json(a) == j);
}
SECTION("std::forward_list<json>")
{
std::forward_list<json> a = j.get<std::forward_list<json>>();
CHECK(json(a) == j);
}
SECTION("std::vector<json>")
{
std::vector<json> a = j.get<std::vector<json>>();
CHECK(json(a) == j);
}
SECTION("std::deque<json>")
{
std::deque<json> a = j.get<std::deque<json>>();
CHECK(json(a) == j);
}
}
} }