mirror of
https://github.com/nlohmann/json.git
synced 2026-11-22 10:54:22 +00:00
Compare commits
2
Commits
57428501b5
...
315a1daada
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
315a1daada | ||
|
|
c3a69837de |
@@ -1578,7 +1578,15 @@ void check_boolean_get_parity()
|
||||
CHECK(view_value == static_cast<T>(b));
|
||||
}
|
||||
#else
|
||||
CHECK(j.get<T>() == d.root().template get<T>());
|
||||
// without exceptions, the combinations that throw (number_integer_t, number_unsigned_t, number_float_t)
|
||||
// cannot be run: JSON_THROW aborts
|
||||
const bool throws = std::is_same<T, json::number_integer_t>::value
|
||||
|| std::is_same<T, json::number_unsigned_t>::value
|
||||
|| std::is_same<T, json::number_float_t>::value;
|
||||
if (!throws)
|
||||
{
|
||||
CHECK(j.get<T>() == d.root().template get<T>());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -1608,9 +1616,9 @@ TEST_CASE("json_view get<T>() of a boolean (#5988)")
|
||||
SECTION("the exceptions of the exact number types")
|
||||
{
|
||||
const json_document d = json_document::parse("true");
|
||||
CHECK_THROWS_WITH_AS(d.root().get<json::number_integer_t>(), "[json.exception.type_error.302] type must be number, but is boolean", json::type_error&);
|
||||
CHECK_THROWS_WITH_AS(d.root().get<json::number_unsigned_t>(), "[json.exception.type_error.302] type must be number, but is boolean", json::type_error&);
|
||||
CHECK_THROWS_WITH_AS(d.root().get<json::number_float_t>(), "[json.exception.type_error.302] type must be number, but is boolean", json::type_error&);
|
||||
CHECK_THROWS_WITH_AS(d.root().get<json::number_integer_t>(), json_view_test::message("type_error.302", "", 0, 4, "type must be number, but is boolean").c_str(), json::type_error&);
|
||||
CHECK_THROWS_WITH_AS(d.root().get<json::number_unsigned_t>(), json_view_test::message("type_error.302", "", 0, 4, "type must be number, but is boolean").c_str(), json::type_error&);
|
||||
CHECK_THROWS_WITH_AS(d.root().get<json::number_float_t>(), json_view_test::message("type_error.302", "", 0, 4, "type must be number, but is boolean").c_str(), json::type_error&);
|
||||
CHECK(d.root().get<int>() == 1);
|
||||
// get_to() and value() go through get<T>()
|
||||
json::number_float_t x = 0;
|
||||
|
||||
Reference in new issue
Block a user