🎨 use Clang-Format

This commit is contained in:
Niels Lohmann
2023-11-29 15:02:51 +01:00
parent d16f4496eb
commit 286f0c7647
102 changed files with 15937 additions and 11289 deletions
+26 -14
View File
@@ -14,13 +14,11 @@ using nlohmann::json;
TEST_CASE("reference access")
{
// create a JSON value with different types
const json json_types =
{
{"boolean", true},
{"number", {{"integer", 42}, {"floating-point", 17.23}}},
{"string", "Hello, world!"},
{"array", {1, 2, 3, 4, 5}},
{"null", nullptr}};
const json json_types = {{"boolean", true},
{"number", {{"integer", 42}, {"floating-point", 17.23}}},
{"string", "Hello, world!"},
{"array", {1, 2, 3, 4, 5}},
{"null", nullptr}};
SECTION("reference access to object_t")
{
@@ -246,7 +244,9 @@ TEST_CASE("reference access")
//CHECK_THROWS_WITH_AS(value.get_ref<json::number_integer_t&>(),
// "[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number", json::type_error&);
CHECK_NOTHROW(value.get_ref<json::number_unsigned_t&>());
CHECK_THROWS_WITH_AS(value.get_ref<json::number_float_t&>(), "[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number", json::type_error&);
CHECK_THROWS_WITH_AS(value.get_ref<json::number_float_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number",
json::type_error&);
}
SECTION("reference access to number_float_t")
@@ -264,12 +264,24 @@ TEST_CASE("reference access")
CHECK(p2 == value.get<test_type>());
// check if mismatching references throw correctly
CHECK_THROWS_WITH_AS(value.get_ref<json::object_t&>(), "[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number", json::type_error&);
CHECK_THROWS_WITH_AS(value.get_ref<json::array_t&>(), "[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number", json::type_error&);
CHECK_THROWS_WITH_AS(value.get_ref<json::string_t&>(), "[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number", json::type_error&);
CHECK_THROWS_WITH_AS(value.get_ref<json::boolean_t&>(), "[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number", json::type_error&);
CHECK_THROWS_WITH_AS(value.get_ref<json::number_integer_t&>(), "[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number", json::type_error&);
CHECK_THROWS_WITH_AS(value.get_ref<json::number_unsigned_t&>(), "[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number", json::type_error&);
CHECK_THROWS_WITH_AS(value.get_ref<json::object_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number",
json::type_error&);
CHECK_THROWS_WITH_AS(value.get_ref<json::array_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number",
json::type_error&);
CHECK_THROWS_WITH_AS(value.get_ref<json::string_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number",
json::type_error&);
CHECK_THROWS_WITH_AS(value.get_ref<json::boolean_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number",
json::type_error&);
CHECK_THROWS_WITH_AS(value.get_ref<json::number_integer_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number",
json::type_error&);
CHECK_THROWS_WITH_AS(value.get_ref<json::number_unsigned_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number",
json::type_error&);
CHECK_NOTHROW(value.get_ref<json::number_float_t&>());
}
}