mirror of
https://github.com/nlohmann/json.git
synced 2025-07-21 04:22:05 +03:00
🔨 fixed some pedantic GCC warnings
This commit is contained in:
@ -152,7 +152,7 @@ TEST_CASE("modifiers")
|
||||
SECTION("other type")
|
||||
{
|
||||
json j = 1;
|
||||
CHECK_THROWS_AS(j.push_back("Hello"), json::type_error);
|
||||
CHECK_THROWS_AS(j.push_back("Hello"), json::type_error&);
|
||||
CHECK_THROWS_WITH(j.push_back("Hello"), "[json.exception.type_error.308] cannot use push_back() with number");
|
||||
}
|
||||
}
|
||||
@ -182,7 +182,7 @@ TEST_CASE("modifiers")
|
||||
{
|
||||
json j = 1;
|
||||
json k("Hello");
|
||||
CHECK_THROWS_AS(j.push_back(k), json::type_error);
|
||||
CHECK_THROWS_AS(j.push_back(k), json::type_error&);
|
||||
CHECK_THROWS_WITH(j.push_back(k), "[json.exception.type_error.308] cannot use push_back() with number");
|
||||
}
|
||||
}
|
||||
@ -215,7 +215,7 @@ TEST_CASE("modifiers")
|
||||
{
|
||||
json j = 1;
|
||||
json k("Hello");
|
||||
CHECK_THROWS_AS(j.push_back(json::object_t::value_type({"one", 1})), json::type_error);
|
||||
CHECK_THROWS_AS(j.push_back(json::object_t::value_type({"one", 1})), json::type_error&);
|
||||
CHECK_THROWS_WITH(j.push_back(json::object_t::value_type({"one", 1})),
|
||||
"[json.exception.type_error.308] cannot use push_back() with number");
|
||||
}
|
||||
@ -252,7 +252,7 @@ TEST_CASE("modifiers")
|
||||
CHECK(j == json({{"key1", 1}, {"key2", "bar"}}));
|
||||
|
||||
json k = {{"key1", 1}};
|
||||
CHECK_THROWS_AS(k.push_back({1, 2, 3, 4}), json::type_error);
|
||||
CHECK_THROWS_AS(k.push_back({1, 2, 3, 4}), json::type_error&);
|
||||
CHECK_THROWS_WITH(k.push_back({1, 2, 3, 4}), "[json.exception.type_error.308] cannot use push_back() with object");
|
||||
}
|
||||
}
|
||||
@ -291,7 +291,7 @@ TEST_CASE("modifiers")
|
||||
SECTION("other type")
|
||||
{
|
||||
json j = 1;
|
||||
CHECK_THROWS_AS(j.emplace_back("Hello"), json::type_error);
|
||||
CHECK_THROWS_AS(j.emplace_back("Hello"), json::type_error&);
|
||||
CHECK_THROWS_WITH(j.emplace_back("Hello"),
|
||||
"[json.exception.type_error.311] cannot use emplace_back() with number");
|
||||
}
|
||||
@ -351,7 +351,7 @@ TEST_CASE("modifiers")
|
||||
SECTION("other type")
|
||||
{
|
||||
json j = 1;
|
||||
CHECK_THROWS_AS(j.emplace("foo", "bar"), json::type_error);
|
||||
CHECK_THROWS_AS(j.emplace("foo", "bar"), json::type_error&);
|
||||
CHECK_THROWS_WITH(j.emplace("foo", "bar"),
|
||||
"[json.exception.type_error.311] cannot use emplace() with number");
|
||||
}
|
||||
@ -383,7 +383,7 @@ TEST_CASE("modifiers")
|
||||
SECTION("other type")
|
||||
{
|
||||
json j = 1;
|
||||
CHECK_THROWS_AS(j += "Hello", json::type_error);
|
||||
CHECK_THROWS_AS(j += "Hello", json::type_error&);
|
||||
CHECK_THROWS_WITH(j += "Hello", "[json.exception.type_error.308] cannot use push_back() with number");
|
||||
}
|
||||
}
|
||||
@ -413,7 +413,7 @@ TEST_CASE("modifiers")
|
||||
{
|
||||
json j = 1;
|
||||
json k("Hello");
|
||||
CHECK_THROWS_AS(j += k, json::type_error);
|
||||
CHECK_THROWS_AS(j += k, json::type_error&);
|
||||
CHECK_THROWS_WITH(j += k, "[json.exception.type_error.308] cannot use push_back() with number");
|
||||
}
|
||||
}
|
||||
@ -446,7 +446,7 @@ TEST_CASE("modifiers")
|
||||
{
|
||||
json j = 1;
|
||||
json k("Hello");
|
||||
CHECK_THROWS_AS(j += json::object_t::value_type({"one", 1}), json::type_error);
|
||||
CHECK_THROWS_AS(j += json::object_t::value_type({"one", 1}), json::type_error&);
|
||||
CHECK_THROWS_WITH(j += json::object_t::value_type({"one", 1}),
|
||||
"[json.exception.type_error.308] cannot use push_back() with number");
|
||||
}
|
||||
@ -483,7 +483,7 @@ TEST_CASE("modifiers")
|
||||
CHECK(j == json({{"key1", 1}, {"key2", "bar"}}));
|
||||
|
||||
json k = {{"key1", 1}};
|
||||
CHECK_THROWS_AS((k += {1, 2, 3, 4}), json::type_error);
|
||||
CHECK_THROWS_AS((k += {1, 2, 3, 4}), json::type_error&);
|
||||
CHECK_THROWS_WITH((k += {1, 2, 3, 4}), "[json.exception.type_error.308] cannot use push_back() with object");
|
||||
}
|
||||
}
|
||||
@ -620,9 +620,9 @@ TEST_CASE("modifiers")
|
||||
json j_other_array2 = {"first", "second"};
|
||||
|
||||
CHECK_THROWS_AS(j_array.insert(j_array.end(), j_array.begin(), j_array.end()),
|
||||
json::invalid_iterator);
|
||||
json::invalid_iterator&);
|
||||
CHECK_THROWS_AS(j_array.insert(j_array.end(), j_other_array.begin(), j_other_array2.end()),
|
||||
json::invalid_iterator);
|
||||
json::invalid_iterator&);
|
||||
|
||||
CHECK_THROWS_WITH(j_array.insert(j_array.end(), j_array.begin(), j_array.end()),
|
||||
"[json.exception.invalid_iterator.211] passed iterators may not belong to container");
|
||||
@ -652,9 +652,9 @@ TEST_CASE("modifiers")
|
||||
{
|
||||
json j_other_array2 = {"first", "second"};
|
||||
|
||||
CHECK_THROWS_AS(j_array.insert(j_object2.begin(), j_object2.end()), json::type_error);
|
||||
CHECK_THROWS_AS(j_object1.insert(j_object1.begin(), j_object2.end()), json::invalid_iterator);
|
||||
CHECK_THROWS_AS(j_object1.insert(j_array.begin(), j_array.end()), json::invalid_iterator);
|
||||
CHECK_THROWS_AS(j_array.insert(j_object2.begin(), j_object2.end()), json::type_error&);
|
||||
CHECK_THROWS_AS(j_object1.insert(j_object1.begin(), j_object2.end()), json::invalid_iterator&);
|
||||
CHECK_THROWS_AS(j_object1.insert(j_array.begin(), j_array.end()), json::invalid_iterator&);
|
||||
|
||||
CHECK_THROWS_WITH(j_array.insert(j_object2.begin(), j_object2.end()),
|
||||
"[json.exception.type_error.309] cannot use insert() with array");
|
||||
@ -700,11 +700,11 @@ TEST_CASE("modifiers")
|
||||
// pass iterator to a different array
|
||||
json j_another_array = {1, 2};
|
||||
json j_yet_another_array = {"first", "second"};
|
||||
CHECK_THROWS_AS(j_array.insert(j_another_array.end(), 10), json::invalid_iterator);
|
||||
CHECK_THROWS_AS(j_array.insert(j_another_array.end(), j_value), json::invalid_iterator);
|
||||
CHECK_THROWS_AS(j_array.insert(j_another_array.end(), 10, 11), json::invalid_iterator);
|
||||
CHECK_THROWS_AS(j_array.insert(j_another_array.end(), j_yet_another_array.begin(), j_yet_another_array.end()), json::invalid_iterator);
|
||||
CHECK_THROWS_AS(j_array.insert(j_another_array.end(), {1, 2, 3, 4}), json::invalid_iterator);
|
||||
CHECK_THROWS_AS(j_array.insert(j_another_array.end(), 10), json::invalid_iterator&);
|
||||
CHECK_THROWS_AS(j_array.insert(j_another_array.end(), j_value), json::invalid_iterator&);
|
||||
CHECK_THROWS_AS(j_array.insert(j_another_array.end(), 10, 11), json::invalid_iterator&);
|
||||
CHECK_THROWS_AS(j_array.insert(j_another_array.end(), j_yet_another_array.begin(), j_yet_another_array.end()), json::invalid_iterator&);
|
||||
CHECK_THROWS_AS(j_array.insert(j_another_array.end(), {1, 2, 3, 4}), json::invalid_iterator&);
|
||||
|
||||
CHECK_THROWS_WITH(j_array.insert(j_another_array.end(), 10),
|
||||
"[json.exception.invalid_iterator.202] iterator does not fit current value");
|
||||
@ -723,12 +723,12 @@ TEST_CASE("modifiers")
|
||||
// call insert on a non-array type
|
||||
json j_nonarray = 3;
|
||||
json j_yet_another_array = {"first", "second"};
|
||||
CHECK_THROWS_AS(j_nonarray.insert(j_nonarray.end(), 10), json::type_error);
|
||||
CHECK_THROWS_AS(j_nonarray.insert(j_nonarray.end(), j_value), json::type_error);
|
||||
CHECK_THROWS_AS(j_nonarray.insert(j_nonarray.end(), 10, 11), json::type_error);
|
||||
CHECK_THROWS_AS(j_nonarray.insert(j_nonarray.end(), 10), json::type_error&);
|
||||
CHECK_THROWS_AS(j_nonarray.insert(j_nonarray.end(), j_value), json::type_error&);
|
||||
CHECK_THROWS_AS(j_nonarray.insert(j_nonarray.end(), 10, 11), json::type_error&);
|
||||
CHECK_THROWS_AS(j_nonarray.insert(j_nonarray.end(), j_yet_another_array.begin(),
|
||||
j_yet_another_array.end()), json::type_error);
|
||||
CHECK_THROWS_AS(j_nonarray.insert(j_nonarray.end(), {1, 2, 3, 4}), json::type_error);
|
||||
j_yet_another_array.end()), json::type_error&);
|
||||
CHECK_THROWS_AS(j_nonarray.insert(j_nonarray.end(), {1, 2, 3, 4}), json::type_error&);
|
||||
|
||||
CHECK_THROWS_WITH(j_nonarray.insert(j_nonarray.end(), 10), "[json.exception.type_error.309] cannot use insert() with number");
|
||||
CHECK_THROWS_WITH(j_nonarray.insert(j_nonarray.end(), j_value), "[json.exception.type_error.309] cannot use insert() with number");
|
||||
@ -788,7 +788,7 @@ TEST_CASE("modifiers")
|
||||
json j = 17;
|
||||
json::array_t a = {"foo", "bar", "baz"};
|
||||
|
||||
CHECK_THROWS_AS(j.swap(a), json::type_error);
|
||||
CHECK_THROWS_AS(j.swap(a), json::type_error&);
|
||||
CHECK_THROWS_WITH(j.swap(a), "[json.exception.type_error.310] cannot use swap() with number");
|
||||
}
|
||||
}
|
||||
@ -814,7 +814,7 @@ TEST_CASE("modifiers")
|
||||
json j = 17;
|
||||
json::object_t o = {{"cow", "Kuh"}, {"chicken", "Huhn"}};
|
||||
|
||||
CHECK_THROWS_AS(j.swap(o), json::type_error);
|
||||
CHECK_THROWS_AS(j.swap(o), json::type_error&);
|
||||
CHECK_THROWS_WITH(j.swap(o), "[json.exception.type_error.310] cannot use swap() with number");
|
||||
}
|
||||
}
|
||||
@ -840,7 +840,7 @@ TEST_CASE("modifiers")
|
||||
json j = 17;
|
||||
json::string_t s = "Hallo Welt";
|
||||
|
||||
CHECK_THROWS_AS(j.swap(s), json::type_error);
|
||||
CHECK_THROWS_AS(j.swap(s), json::type_error&);
|
||||
CHECK_THROWS_WITH(j.swap(s), "[json.exception.type_error.310] cannot use swap() with number");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user