🚨 fix warnings

This commit is contained in:
Niels Lohmann 2021-01-28 14:46:29 +01:00
parent 675f07f5e9
commit 28d5f863b3
No known key found for this signature in database
GPG Key ID: 7F3CEA63AE251B69
3 changed files with 38 additions and 42 deletions

View File

@ -202,7 +202,7 @@ TEST_CASE("element access 2")
SECTION("null")
{
json j_nonobject(json::value_t::null);
const json j_nonobject_const(j_nonobject);
const json j_nonobject_const(json::value_t::null);
CHECK_THROWS_AS(j_nonobject.value("foo", 1), json::type_error&);
CHECK_THROWS_AS(j_nonobject_const.value("foo", 1), json::type_error&);
CHECK_THROWS_WITH(j_nonobject.value("foo", 1),
@ -214,7 +214,7 @@ TEST_CASE("element access 2")
SECTION("boolean")
{
json j_nonobject(json::value_t::boolean);
const json j_nonobject_const(j_nonobject);
const json j_nonobject_const(json::value_t::boolean);
CHECK_THROWS_AS(j_nonobject.value("foo", 1), json::type_error&);
CHECK_THROWS_AS(j_nonobject_const.value("foo", 1), json::type_error&);
CHECK_THROWS_WITH(j_nonobject.value("foo", 1),
@ -226,7 +226,7 @@ TEST_CASE("element access 2")
SECTION("string")
{
json j_nonobject(json::value_t::string);
const json j_nonobject_const(j_nonobject);
const json j_nonobject_const(json::value_t::string);
CHECK_THROWS_AS(j_nonobject.value("foo", 1), json::type_error&);
CHECK_THROWS_AS(j_nonobject_const.value("foo", 1), json::type_error&);
CHECK_THROWS_WITH(j_nonobject.value("foo", 1),
@ -238,7 +238,7 @@ TEST_CASE("element access 2")
SECTION("array")
{
json j_nonobject(json::value_t::array);
const json j_nonobject_const(j_nonobject);
const json j_nonobject_const(json::value_t::array);
CHECK_THROWS_AS(j_nonobject.value("foo", 1), json::type_error&);
CHECK_THROWS_AS(j_nonobject_const.value("foo", 1), json::type_error&);
CHECK_THROWS_WITH(j_nonobject.value("foo", 1),
@ -250,7 +250,7 @@ TEST_CASE("element access 2")
SECTION("number (integer)")
{
json j_nonobject(json::value_t::number_integer);
const json j_nonobject_const(j_nonobject);
const json j_nonobject_const(json::value_t::number_integer);
CHECK_THROWS_AS(j_nonobject.value("foo", 1), json::type_error&);
CHECK_THROWS_AS(j_nonobject_const.value("foo", 1), json::type_error&);
CHECK_THROWS_WITH(j_nonobject.value("foo", 1),
@ -262,7 +262,7 @@ TEST_CASE("element access 2")
SECTION("number (unsigned)")
{
json j_nonobject(json::value_t::number_unsigned);
const json j_nonobject_const(j_nonobject);
const json j_nonobject_const(json::value_t::number_unsigned);
CHECK_THROWS_AS(j_nonobject.value("foo", 1), json::type_error&);
CHECK_THROWS_AS(j_nonobject_const.value("foo", 1), json::type_error&);
CHECK_THROWS_WITH(j_nonobject.value("foo", 1),
@ -274,7 +274,7 @@ TEST_CASE("element access 2")
SECTION("number (floating-point)")
{
json j_nonobject(json::value_t::number_float);
const json j_nonobject_const(j_nonobject);
const json j_nonobject_const(json::value_t::number_float);
CHECK_THROWS_AS(j_nonobject.value("foo", 1), json::type_error&);
CHECK_THROWS_AS(j_nonobject_const.value("foo", 1), json::type_error&);
CHECK_THROWS_WITH(j_nonobject.value("foo", 1),
@ -320,7 +320,7 @@ TEST_CASE("element access 2")
SECTION("null")
{
json j_nonobject(json::value_t::null);
const json j_nonobject_const(j_nonobject);
const json j_nonobject_const(json::value_t::null);
CHECK_THROWS_AS(j_nonobject.value("/foo"_json_pointer, 1), json::type_error&);
CHECK_THROWS_AS(j_nonobject_const.value("/foo"_json_pointer, 1), json::type_error&);
CHECK_THROWS_WITH(j_nonobject.value("/foo"_json_pointer, 1),
@ -332,7 +332,7 @@ TEST_CASE("element access 2")
SECTION("boolean")
{
json j_nonobject(json::value_t::boolean);
const json j_nonobject_const(j_nonobject);
const json j_nonobject_const(json::value_t::boolean);
CHECK_THROWS_AS(j_nonobject.value("/foo"_json_pointer, 1), json::type_error&);
CHECK_THROWS_AS(j_nonobject_const.value("/foo"_json_pointer, 1), json::type_error&);
CHECK_THROWS_WITH(j_nonobject.value("/foo"_json_pointer, 1),
@ -344,7 +344,7 @@ TEST_CASE("element access 2")
SECTION("string")
{
json j_nonobject(json::value_t::string);
const json j_nonobject_const(j_nonobject);
const json j_nonobject_const(json::value_t::string);
CHECK_THROWS_AS(j_nonobject.value("/foo"_json_pointer, 1), json::type_error&);
CHECK_THROWS_AS(j_nonobject_const.value("/foo"_json_pointer, 1), json::type_error&);
CHECK_THROWS_WITH(j_nonobject.value("/foo"_json_pointer, 1),
@ -356,7 +356,7 @@ TEST_CASE("element access 2")
SECTION("array")
{
json j_nonobject(json::value_t::array);
const json j_nonobject_const(j_nonobject);
const json j_nonobject_const(json::value_t::array);
CHECK_THROWS_AS(j_nonobject.value("/foo"_json_pointer, 1), json::type_error&);
CHECK_THROWS_AS(j_nonobject_const.value("/foo"_json_pointer, 1), json::type_error&);
CHECK_THROWS_WITH(j_nonobject.value("/foo"_json_pointer, 1),
@ -368,7 +368,7 @@ TEST_CASE("element access 2")
SECTION("number (integer)")
{
json j_nonobject(json::value_t::number_integer);
const json j_nonobject_const(j_nonobject);
const json j_nonobject_const(json::value_t::number_integer);
CHECK_THROWS_AS(j_nonobject.value("/foo"_json_pointer, 1), json::type_error&);
CHECK_THROWS_AS(j_nonobject_const.value("/foo"_json_pointer, 1), json::type_error&);
CHECK_THROWS_WITH(j_nonobject.value("/foo"_json_pointer, 1),
@ -380,7 +380,7 @@ TEST_CASE("element access 2")
SECTION("number (unsigned)")
{
json j_nonobject(json::value_t::number_unsigned);
const json j_nonobject_const(j_nonobject);
const json j_nonobject_const(json::value_t::number_unsigned);
CHECK_THROWS_AS(j_nonobject.value("/foo"_json_pointer, 1), json::type_error&);
CHECK_THROWS_AS(j_nonobject_const.value("/foo"_json_pointer, 1), json::type_error&);
CHECK_THROWS_WITH(j_nonobject.value("/foo"_json_pointer, 1),
@ -392,7 +392,7 @@ TEST_CASE("element access 2")
SECTION("number (floating-point)")
{
json j_nonobject(json::value_t::number_float);
const json j_nonobject_const(j_nonobject);
const json j_nonobject_const(json::value_t::number_float);
CHECK_THROWS_AS(j_nonobject.value("/foo"_json_pointer, 1), json::type_error&);
CHECK_THROWS_AS(j_nonobject_const.value("/foo"_json_pointer, 1), json::type_error&);
CHECK_THROWS_WITH(j_nonobject.value("/foo"_json_pointer, 1),
@ -811,7 +811,7 @@ TEST_CASE("element access 2")
{
SECTION("existing element")
{
for (auto key :
for (const auto *key :
{"integer", "unsigned", "floating", "null", "string", "boolean", "object", "array"
})
{
@ -900,7 +900,7 @@ TEST_CASE("element access 2")
{
SECTION("existing element")
{
for (auto key :
for (const auto *key :
{"integer", "unsigned", "floating", "null", "string", "boolean", "object", "array"
})
{
@ -920,7 +920,7 @@ TEST_CASE("element access 2")
SECTION("null")
{
json j_nonobject(json::value_t::null);
const json j_nonobject_const(j_nonobject);
const json j_nonobject_const(json::value_t::null);
CHECK(j_nonobject.count("foo") == 0);
CHECK(j_nonobject_const.count("foo") == 0);
}
@ -928,7 +928,7 @@ TEST_CASE("element access 2")
SECTION("string")
{
json j_nonobject(json::value_t::string);
const json j_nonobject_const(j_nonobject);
const json j_nonobject_const(json::value_t::string);
CHECK(j_nonobject.count("foo") == 0);
CHECK(j_nonobject_const.count("foo") == 0);
}
@ -936,7 +936,7 @@ TEST_CASE("element access 2")
SECTION("object")
{
json j_nonobject(json::value_t::object);
const json j_nonobject_const(j_nonobject);
const json j_nonobject_const(json::value_t::object);
CHECK(j_nonobject.count("foo") == 0);
CHECK(j_nonobject_const.count("foo") == 0);
}
@ -944,7 +944,7 @@ TEST_CASE("element access 2")
SECTION("array")
{
json j_nonobject(json::value_t::array);
const json j_nonobject_const(j_nonobject);
const json j_nonobject_const(json::value_t::array);
CHECK(j_nonobject.count("foo") == 0);
CHECK(j_nonobject_const.count("foo") == 0);
}
@ -952,7 +952,7 @@ TEST_CASE("element access 2")
SECTION("boolean")
{
json j_nonobject(json::value_t::boolean);
const json j_nonobject_const(j_nonobject);
const json j_nonobject_const(json::value_t::boolean);
CHECK(j_nonobject.count("foo") == 0);
CHECK(j_nonobject_const.count("foo") == 0);
}
@ -960,7 +960,7 @@ TEST_CASE("element access 2")
SECTION("number (integer)")
{
json j_nonobject(json::value_t::number_integer);
const json j_nonobject_const(j_nonobject);
const json j_nonobject_const(json::value_t::number_integer);
CHECK(j_nonobject.count("foo") == 0);
CHECK(j_nonobject_const.count("foo") == 0);
}
@ -968,7 +968,7 @@ TEST_CASE("element access 2")
SECTION("number (unsigned)")
{
json j_nonobject(json::value_t::number_unsigned);
const json j_nonobject_const(j_nonobject);
const json j_nonobject_const(json::value_t::number_unsigned);
CHECK(j_nonobject.count("foo") == 0);
CHECK(j_nonobject_const.count("foo") == 0);
}
@ -976,7 +976,7 @@ TEST_CASE("element access 2")
SECTION("number (floating-point)")
{
json j_nonobject(json::value_t::number_float);
const json j_nonobject_const(j_nonobject);
const json j_nonobject_const(json::value_t::number_float);
CHECK(j_nonobject.count("foo") == 0);
CHECK(j_nonobject_const.count("foo") == 0);
}
@ -987,7 +987,7 @@ TEST_CASE("element access 2")
{
SECTION("existing element")
{
for (auto key :
for (const auto *key :
{"integer", "unsigned", "floating", "null", "string", "boolean", "object", "array"
})
{
@ -1007,7 +1007,7 @@ TEST_CASE("element access 2")
SECTION("null")
{
json j_nonobject(json::value_t::null);
const json j_nonobject_const(j_nonobject);
const json j_nonobject_const(json::value_t::null);
CHECK(j_nonobject.contains("foo") == false);
CHECK(j_nonobject_const.contains("foo") == false);
}
@ -1015,7 +1015,7 @@ TEST_CASE("element access 2")
SECTION("string")
{
json j_nonobject(json::value_t::string);
const json j_nonobject_const(j_nonobject);
const json j_nonobject_const(json::value_t::string);
CHECK(j_nonobject.contains("foo") == false);
CHECK(j_nonobject_const.contains("foo") == false);
}
@ -1023,7 +1023,7 @@ TEST_CASE("element access 2")
SECTION("object")
{
json j_nonobject(json::value_t::object);
const json j_nonobject_const(j_nonobject);
const json j_nonobject_const(json::value_t::object);
CHECK(j_nonobject.contains("foo") == false);
CHECK(j_nonobject_const.contains("foo") == false);
}
@ -1031,7 +1031,7 @@ TEST_CASE("element access 2")
SECTION("array")
{
json j_nonobject(json::value_t::array);
const json j_nonobject_const(j_nonobject);
const json j_nonobject_const(json::value_t::array);
CHECK(j_nonobject.contains("foo") == false);
CHECK(j_nonobject_const.contains("foo") == false);
}
@ -1039,7 +1039,7 @@ TEST_CASE("element access 2")
SECTION("boolean")
{
json j_nonobject(json::value_t::boolean);
const json j_nonobject_const(j_nonobject);
const json j_nonobject_const(json::value_t::boolean);
CHECK(j_nonobject.contains("foo") == false);
CHECK(j_nonobject_const.contains("foo") == false);
}
@ -1047,7 +1047,7 @@ TEST_CASE("element access 2")
SECTION("number (integer)")
{
json j_nonobject(json::value_t::number_integer);
const json j_nonobject_const(j_nonobject);
const json j_nonobject_const(json::value_t::number_integer);
CHECK(j_nonobject.contains("foo") == false);
CHECK(j_nonobject_const.contains("foo") == false);
}
@ -1055,7 +1055,7 @@ TEST_CASE("element access 2")
SECTION("number (unsigned)")
{
json j_nonobject(json::value_t::number_unsigned);
const json j_nonobject_const(j_nonobject);
const json j_nonobject_const(json::value_t::number_unsigned);
CHECK(j_nonobject.contains("foo") == false);
CHECK(j_nonobject_const.contains("foo") == false);
}
@ -1063,7 +1063,7 @@ TEST_CASE("element access 2")
SECTION("number (floating-point)")
{
json j_nonobject(json::value_t::number_float);
const json j_nonobject_const(j_nonobject);
const json j_nonobject_const(json::value_t::number_float);
CHECK(j_nonobject.contains("foo") == false);
CHECK(j_nonobject_const.contains("foo") == false);
}
@ -1078,7 +1078,7 @@ TEST_CASE("element access 2 (throwing tests)")
SECTION("object")
{
json j = {{"integer", 1}, {"unsigned", 1u}, {"floating", 42.23}, {"null", nullptr}, {"string", "hello world"}, {"boolean", true}, {"object", json::object()}, {"array", {1, 2, 3}}};
const json j_const = j;
const json j_const = {{"integer", 1}, {"unsigned", 1u}, {"floating", 42.23}, {"null", nullptr}, {"string", "hello world"}, {"boolean", true}, {"object", json::object()}, {"array", {1, 2, 3}}};
SECTION("access specified element with default value")
{

View File

@ -1109,7 +1109,7 @@ TEST_CASE("regression tests 1")
CHECK_TYPE(0u)
CHECK_TYPE(0L)
CHECK_TYPE(0.0)
CHECK_TYPE("")
CHECK_TYPE("") // NOLINT(readability-container-size-empty)
#undef CHECK_TYPE
}
@ -1443,8 +1443,8 @@ TEST_CASE("regression tests 1")
SECTION("issue #838 - incorrect parse error with binary data in keys")
{
uint8_t key1[] = { 103, 92, 117, 48, 48, 48, 55, 92, 114, 215, 126, 214, 95, 92, 34, 174, 40, 71, 38, 174, 40, 71, 38, 223, 134, 247, 127, 0 };
std::string key1_str(reinterpret_cast<char*>(key1));
std::array<uint8_t, 28> key1 = { 103, 92, 117, 48, 48, 48, 55, 92, 114, 215, 126, 214, 95, 92, 34, 174, 40, 71, 38, 174, 40, 71, 38, 223, 134, 247, 127, 0 };
std::string key1_str(reinterpret_cast<char*>(key1.data()));
json j = key1_str;
CHECK_THROWS_AS(j.dump(), json::type_error&);
CHECK_THROWS_WITH(j.dump(), "[json.exception.type_error.316] invalid UTF-8 byte at index 10: 0x7E");

View File

@ -235,13 +235,9 @@ TEST_CASE("compliance tests from nativejson-benchmark")
5708990770823839524233143877797980545530986496.0);
{
char n1e308[312]; // '1' followed by 308 '0'
std::string n1e308(312, '0'); // '1' followed by 308 '0'
n1e308[0] = '[';
n1e308[1] = '1';
for (int j = 2; j < 310; j++)
{
n1e308[j] = '0';
}
n1e308[310] = ']';
n1e308[311] = '\0';
TEST_DOUBLE(n1e308, 1E308);