improved test case coverage

This commit is contained in:
Niels 2015-04-08 22:58:35 +02:00
parent 1bdb6acb1f
commit 9e8e11339d
2 changed files with 13 additions and 1 deletions

View file

@ -379,7 +379,7 @@ $ make
$ ./json_unit $ ./json_unit
=============================================================================== ===============================================================================
All tests passed (4280 assertions in 16 test cases) All tests passed (4332 assertions in 18 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).

View file

@ -2050,6 +2050,11 @@ TEST_CASE("value conversion")
//auto m4 = j4.get<std::unordered_multimap<std::string, std::string>>(); //auto m4 = j4.get<std::unordered_multimap<std::string, std::string>>();
//CHECK(m4["one"] == "eins"); //CHECK(m4["one"] == "eins");
} }
SECTION("exception in case of a non-object type")
{
CHECK_THROWS_AS((json().get<std::map<std::string, int>>()), std::logic_error);
}
} }
SECTION("array-like STL containers") SECTION("array-like STL containers")
@ -2106,6 +2111,13 @@ TEST_CASE("value conversion")
auto m3 = j3.get<std::unordered_set<bool>>(); auto m3 = j3.get<std::unordered_set<bool>>();
auto m4 = j4.get<std::unordered_set<std::string>>(); auto m4 = j4.get<std::unordered_set<std::string>>();
} }
SECTION("exception in case of a non-object type")
{
CHECK_THROWS_AS((json().get<std::list<int>>()), std::logic_error);
CHECK_THROWS_AS((json().get<std::vector<int>>()), std::logic_error);
CHECK_THROWS_AS((json().get<std::vector<json>>()), std::logic_error);
}
} }
} }
} }