📝 cleanup after the last PRs

This commit is contained in:
Niels Lohmann 2017-10-22 09:12:35 +02:00
parent be4fba7baf
commit b0c380b0f8
No known key found for this signature in database
GPG key ID: 7F3CEA63AE251B69
6 changed files with 97 additions and 89 deletions

View file

@ -274,7 +274,7 @@ TEST_CASE("modifiers")
// invalid values (no string/val pair)
CHECK_THROWS_AS(j.push_back({1}), json::type_error&);
CHECK_THROWS_WITH(j.push_back({1}), "[json.exception.type_error.308] cannot use push_back() with object");
CHECK_THROWS_AS(j.push_back({1,2}), json::type_error&);
CHECK_THROWS_AS(j.push_back({1, 2}), json::type_error&);
CHECK_THROWS_WITH(j.push_back({1, 2}), "[json.exception.type_error.308] cannot use push_back() with object");
CHECK_THROWS_AS(j.push_back({1, 2, 3, 4}), json::type_error&);
CHECK_THROWS_WITH(j.push_back({1, 2, 3, 4}), "[json.exception.type_error.308] cannot use push_back() with object");

View file

@ -39,8 +39,8 @@ using nlohmann::json;
#include <iostream>
#if defined(_MSC_VER)
#pragma warning (push)
#pragma warning (disable : 4189) // local variable is initialized but not referenced
#pragma warning (push)
#pragma warning (disable : 4189) // local variable is initialized but not referenced
#endif
TEST_CASE("README", "[hide]")
@ -305,5 +305,5 @@ TEST_CASE("README", "[hide]")
}
#if defined(_MSC_VER)
#pragma warning (pop)
#pragma warning (pop)
#endif

View file

@ -66,22 +66,22 @@ TEST_CASE("reference access")
CHECK_NOTHROW(value.get_ref<json::object_t&>());
CHECK_THROWS_AS(value.get_ref<json::array_t&>(), json::type_error&);
CHECK_THROWS_WITH(value.get_ref<json::array_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is object");
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is object");
CHECK_THROWS_AS(value.get_ref<json::string_t&>(), json::type_error&);
CHECK_THROWS_WITH(value.get_ref<json::string_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is object");
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is object");
CHECK_THROWS_AS(value.get_ref<json::boolean_t&>(), json::type_error&);
CHECK_THROWS_WITH(value.get_ref<json::boolean_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is object");
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is object");
CHECK_THROWS_AS(value.get_ref<json::number_integer_t&>(), json::type_error&);
CHECK_THROWS_WITH(value.get_ref<json::number_integer_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is object");
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is object");
CHECK_THROWS_AS(value.get_ref<json::number_unsigned_t&>(), json::type_error&);
CHECK_THROWS_WITH(value.get_ref<json::number_unsigned_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is object");
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is object");
CHECK_THROWS_AS(value.get_ref<json::number_float_t&>(), json::type_error&);
CHECK_THROWS_WITH(value.get_ref<json::number_float_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is object");
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is object");
}
SECTION("const reference access to const object_t")
@ -115,23 +115,23 @@ TEST_CASE("reference access")
// check if mismatching references throw correctly
CHECK_THROWS_AS(value.get_ref<json::object_t&>(), json::type_error&);
CHECK_THROWS_WITH(value.get_ref<json::object_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is array");
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is array");
CHECK_NOTHROW(value.get_ref<json::array_t&>());
CHECK_THROWS_AS(value.get_ref<json::string_t&>(), json::type_error&);
CHECK_THROWS_WITH(value.get_ref<json::string_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is array");
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is array");
CHECK_THROWS_AS(value.get_ref<json::boolean_t&>(), json::type_error&);
CHECK_THROWS_WITH(value.get_ref<json::boolean_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is array");
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is array");
CHECK_THROWS_AS(value.get_ref<json::number_integer_t&>(), json::type_error&);
CHECK_THROWS_WITH(value.get_ref<json::number_integer_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is array");
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is array");
CHECK_THROWS_AS(value.get_ref<json::number_unsigned_t&>(), json::type_error&);
CHECK_THROWS_WITH(value.get_ref<json::number_unsigned_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is array");
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is array");
CHECK_THROWS_AS(value.get_ref<json::number_float_t&>(), json::type_error&);
CHECK_THROWS_WITH(value.get_ref<json::number_float_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is array");
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is array");
}
SECTION("reference access to string_t")
@ -151,23 +151,23 @@ TEST_CASE("reference access")
// check if mismatching references throw correctly
CHECK_THROWS_AS(value.get_ref<json::object_t&>(), json::type_error&);
CHECK_THROWS_WITH(value.get_ref<json::object_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is string");
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is string");
CHECK_THROWS_AS(value.get_ref<json::array_t&>(), json::type_error&);
CHECK_THROWS_WITH(value.get_ref<json::array_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is string");
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is string");
CHECK_NOTHROW(value.get_ref<json::string_t&>());
CHECK_THROWS_AS(value.get_ref<json::boolean_t&>(), json::type_error&);
CHECK_THROWS_WITH(value.get_ref<json::boolean_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is string");
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is string");
CHECK_THROWS_AS(value.get_ref<json::number_integer_t&>(), json::type_error&);
CHECK_THROWS_WITH(value.get_ref<json::number_integer_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is string");
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is string");
CHECK_THROWS_AS(value.get_ref<json::number_unsigned_t&>(), json::type_error&);
CHECK_THROWS_WITH(value.get_ref<json::number_unsigned_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is string");
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is string");
CHECK_THROWS_AS(value.get_ref<json::number_float_t&>(), json::type_error&);
CHECK_THROWS_WITH(value.get_ref<json::number_float_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is string");
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is string");
}
SECTION("reference access to boolean_t")
@ -187,23 +187,23 @@ TEST_CASE("reference access")
// check if mismatching references throw correctly
CHECK_THROWS_AS(value.get_ref<json::object_t&>(), json::type_error&);
CHECK_THROWS_WITH(value.get_ref<json::object_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is boolean");
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is boolean");
CHECK_THROWS_AS(value.get_ref<json::array_t&>(), json::type_error&);
CHECK_THROWS_WITH(value.get_ref<json::array_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is boolean");
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is boolean");
CHECK_THROWS_AS(value.get_ref<json::string_t&>(), json::type_error&);
CHECK_THROWS_WITH(value.get_ref<json::string_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is boolean");
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is boolean");
CHECK_NOTHROW(value.get_ref<json::boolean_t&>());
CHECK_THROWS_AS(value.get_ref<json::number_integer_t&>(), json::type_error&);
CHECK_THROWS_WITH(value.get_ref<json::number_integer_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is boolean");
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is boolean");
CHECK_THROWS_AS(value.get_ref<json::number_unsigned_t&>(), json::type_error&);
CHECK_THROWS_WITH(value.get_ref<json::number_unsigned_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is boolean");
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is boolean");
CHECK_THROWS_AS(value.get_ref<json::number_float_t&>(), json::type_error&);
CHECK_THROWS_WITH(value.get_ref<json::number_float_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is boolean");
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is boolean");
}
SECTION("reference access to number_integer_t")
@ -223,23 +223,23 @@ TEST_CASE("reference access")
// check if mismatching references throw correctly
CHECK_THROWS_AS(value.get_ref<json::object_t&>(), json::type_error&);
CHECK_THROWS_WITH(value.get_ref<json::object_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number");
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number");
CHECK_THROWS_AS(value.get_ref<json::array_t&>(), json::type_error&);
CHECK_THROWS_WITH(value.get_ref<json::array_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number");
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number");
CHECK_THROWS_AS(value.get_ref<json::string_t&>(), json::type_error&);
CHECK_THROWS_WITH(value.get_ref<json::string_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number");
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number");
CHECK_THROWS_AS(value.get_ref<json::boolean_t&>(), json::type_error&);
CHECK_THROWS_WITH(value.get_ref<json::boolean_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number");
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number");
CHECK_NOTHROW(value.get_ref<json::number_integer_t&>());
CHECK_THROWS_AS(value.get_ref<json::number_unsigned_t&>(), json::type_error&);
CHECK_THROWS_WITH(value.get_ref<json::number_unsigned_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number");
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number");
CHECK_THROWS_AS(value.get_ref<json::number_float_t&>(), json::type_error&);
CHECK_THROWS_WITH(value.get_ref<json::number_float_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number");
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number");
}
SECTION("reference access to number_unsigned_t")
@ -259,23 +259,23 @@ TEST_CASE("reference access")
// check if mismatching references throw correctly
CHECK_THROWS_AS(value.get_ref<json::object_t&>(), json::type_error&);
CHECK_THROWS_WITH(value.get_ref<json::object_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number");
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number");
CHECK_THROWS_AS(value.get_ref<json::array_t&>(), json::type_error&);
CHECK_THROWS_WITH(value.get_ref<json::array_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number");
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number");
CHECK_THROWS_AS(value.get_ref<json::string_t&>(), json::type_error&);
CHECK_THROWS_WITH(value.get_ref<json::string_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number");
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number");
CHECK_THROWS_AS(value.get_ref<json::boolean_t&>(), json::type_error&);
CHECK_THROWS_WITH(value.get_ref<json::boolean_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number");
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number");
//CHECK_THROWS_AS(value.get_ref<json::number_integer_t&>(), json::type_error&);
//CHECK_THROWS_WITH(value.get_ref<json::number_integer_t&>(),
// "[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number");
CHECK_NOTHROW(value.get_ref<json::number_unsigned_t&>());
CHECK_THROWS_AS(value.get_ref<json::number_float_t&>(), json::type_error&);
CHECK_THROWS_WITH(value.get_ref<json::number_float_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number");
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number");
}
SECTION("reference access to number_float_t")
@ -295,22 +295,22 @@ TEST_CASE("reference access")
// check if mismatching references throw correctly
CHECK_THROWS_AS(value.get_ref<json::object_t&>(), json::type_error&);
CHECK_THROWS_WITH(value.get_ref<json::object_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number");
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number");
CHECK_THROWS_AS(value.get_ref<json::array_t&>(), json::type_error&);
CHECK_THROWS_WITH(value.get_ref<json::array_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number");
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number");
CHECK_THROWS_AS(value.get_ref<json::string_t&>(), json::type_error&);
CHECK_THROWS_WITH(value.get_ref<json::string_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number");
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number");
CHECK_THROWS_AS(value.get_ref<json::boolean_t&>(), json::type_error&);
CHECK_THROWS_WITH(value.get_ref<json::boolean_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number");
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number");
CHECK_THROWS_AS(value.get_ref<json::number_integer_t&>(), json::type_error&);
CHECK_THROWS_WITH(value.get_ref<json::number_integer_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number");
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number");
CHECK_THROWS_AS(value.get_ref<json::number_unsigned_t&>(), json::type_error&);
CHECK_THROWS_WITH(value.get_ref<json::number_unsigned_t&>(),
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number");
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number");
CHECK_NOTHROW(value.get_ref<json::number_float_t&>());
}
}

View file

@ -1236,21 +1236,21 @@ TEST_CASE("regression tests")
SECTION("issue #367 - Behavior of operator>> should more closely resemble that of built-in overloads.")
{
SECTION("example 1")
{
std::istringstream i1_2_3( "{\"first\": \"one\" }{\"second\": \"two\"}3" );
json j1, j2, j3;
i1_2_3 >> j1;
i1_2_3 >> j2;
i1_2_3 >> j3;
SECTION("example 1")
{
std::istringstream i1_2_3( "{\"first\": \"one\" }{\"second\": \"two\"}3" );
json j1, j2, j3;
i1_2_3 >> j1;
i1_2_3 >> j2;
i1_2_3 >> j3;
std::map<std::string,std::string> m1 = j1;
std::map<std::string,std::string> m2 = j2;
int i3 = j3;
std::map<std::string, std::string> m1 = j1;
std::map<std::string, std::string> m2 = j2;
int i3 = j3;
CHECK( m1 == ( std::map<std::string,std::string> {{ "first", "one" }} ));
CHECK( m2 == ( std::map<std::string,std::string> {{ "second", "two" }} ));
CHECK( i3 == 3 );
}
CHECK( m1 == ( std::map<std::string, std::string> {{ "first", "one" }} ));
CHECK( m2 == ( std::map<std::string, std::string> {{ "second", "two" }} ));
CHECK( i3 == 3 );
}
}
}