🚨 fixed warnings

pull/918/merge
Niels Lohmann 2018-01-30 23:57:49 +01:00
parent f7131715b1
commit 57e6fddd90
No known key found for this signature in database
GPG Key ID: 7F3CEA63AE251B69
6 changed files with 16 additions and 16 deletions

View File

@ -295,11 +295,11 @@ TEST_CASE("constructors")
{
json j{1};
CHECK_THROWS_AS((j.get<std::pair<int, int>>()), json::out_of_range);
CHECK_THROWS_AS((j.get<std::pair<int, int>>()), json::out_of_range&);
CHECK_THROWS_WITH((j.get<std::pair<int, int>>()), "[json.exception.out_of_range.401] array index 1 is out of range");
CHECK_THROWS_AS((j.get<std::tuple<int, int>>()), json::out_of_range);
CHECK_THROWS_AS((j.get<std::tuple<int, int>>()), json::out_of_range&);
CHECK_THROWS_WITH((j.get<std::tuple<int, int>>()), "[json.exception.out_of_range.401] array index 1 is out of range");
CHECK_THROWS_AS((j.get<std::array<int, 3>>()), json::out_of_range);
CHECK_THROWS_AS((j.get<std::array<int, 3>>()), json::out_of_range&);
CHECK_THROWS_WITH((j.get<std::array<int, 3>>()), "[json.exception.out_of_range.401] array index 1 is out of range");
}

View File

@ -99,11 +99,11 @@ TEST_CASE("convenience functions")
check_escaped("\x1f", "\\u001f");
// invalid UTF-8 characters
CHECK_THROWS_AS(check_escaped("ä\xA9ü"), json::type_error);
CHECK_THROWS_AS(check_escaped("ä\xA9ü"), json::type_error&);
CHECK_THROWS_WITH(check_escaped("ä\xA9ü"),
"[json.exception.type_error.316] invalid UTF-8 byte at index 2: 0xA9");
CHECK_THROWS_AS(check_escaped("\xC2"), json::type_error);
CHECK_THROWS_AS(check_escaped("\xC2"), json::type_error&);
CHECK_THROWS_WITH(check_escaped("\xC2"),
"[json.exception.type_error.316] incomplete UTF-8 string; last byte: 0xC2");
}

View File

@ -1020,7 +1020,7 @@ TEST_CASE("value conversion")
SECTION("std::array is larger than JSON")
{
std::array<int, 6> arr6 = {{1, 2, 3, 4, 5, 6}};
CHECK_THROWS_AS(arr6 = j1, json::out_of_range);
CHECK_THROWS_AS(arr6 = j1, json::out_of_range&);
CHECK_THROWS_WITH(arr6 = j1, "[json.exception.out_of_range.401] array index 4 is out of range");
}

View File

@ -60,7 +60,7 @@ TEST_CASE("JSON pointers")
{
json v = {1, 2, 3, 4};
json::json_pointer ptr("/10e");
CHECK_THROWS_AS(v[ptr], json::out_of_range);
CHECK_THROWS_AS(v[ptr], json::out_of_range&);
CHECK_THROWS_WITH(v[ptr],
"[json.exception.out_of_range.404] unresolved reference token '10e'");
}

View File

@ -1369,7 +1369,7 @@ TEST_CASE("regression tests")
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 };
std::string key1_str(key1, key1 + sizeof(key1) / sizeof(key1[0]));
json j = key1_str;
CHECK_THROWS_AS(j.dump(), json::type_error);
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");
}
@ -1394,7 +1394,7 @@ TEST_CASE("regression tests")
CHECK_THROWS_AS(model.patch(R"([{"op": "move",
"from": "/one/two/three",
"path": "/a/b/c"}])"_json), json::out_of_range);
"path": "/a/b/c"}])"_json), json::out_of_range&);
CHECK_THROWS_WITH(model.patch(R"([{"op": "move",
"from": "/one/two/three",
"path": "/a/b/c"}])"_json),
@ -1402,7 +1402,7 @@ TEST_CASE("regression tests")
CHECK_THROWS_AS(model.patch(R"([{"op": "copy",
"from": "/one/two/three",
"path": "/a/b/c"}])"_json), json::out_of_range);
"path": "/a/b/c"}])"_json), json::out_of_range&);
CHECK_THROWS_WITH(model.patch(R"([{"op": "copy",
"from": "/one/two/three",
"path": "/a/b/c"}])"_json),

View File

@ -1186,7 +1186,7 @@ TEST_CASE("UBJSON")
{
// larger than max int64
json j = 9223372036854775808llu;
CHECK_THROWS_AS(json::to_ubjson(j), json::out_of_range);
CHECK_THROWS_AS(json::to_ubjson(j), json::out_of_range&);
CHECK_THROWS_WITH(json::to_ubjson(j), "[json.exception.out_of_range.407] number overflow serializing 9223372036854775808");
}
}
@ -1340,14 +1340,14 @@ TEST_CASE("UBJSON")
SECTION("eof after C byte")
{
std::vector<uint8_t> v = {'C'};
CHECK_THROWS_AS(json::from_ubjson(v), json::parse_error);
CHECK_THROWS_AS(json::from_ubjson(v), json::parse_error&);
CHECK_THROWS_WITH(json::from_ubjson(v), "[json.exception.parse_error.110] parse error at 2: unexpected end of input");
}
SECTION("byte out of range")
{
std::vector<uint8_t> v = {'C', 130};
CHECK_THROWS_AS(json::from_ubjson(v), json::parse_error);
CHECK_THROWS_AS(json::from_ubjson(v), json::parse_error&);
CHECK_THROWS_WITH(json::from_ubjson(v), "[json.exception.parse_error.113] parse error at 2: byte after 'C' must be in range 0x00..0x7F; last byte: 0x82");
}
}
@ -1357,14 +1357,14 @@ TEST_CASE("UBJSON")
SECTION("eof after S byte")
{
std::vector<uint8_t> v = {'S'};
CHECK_THROWS_AS(json::from_ubjson(v), json::parse_error);
CHECK_THROWS_AS(json::from_ubjson(v), json::parse_error&);
CHECK_THROWS_WITH(json::from_ubjson(v), "[json.exception.parse_error.110] parse error at 2: unexpected end of input");
}
SECTION("invalid byte")
{
std::vector<uint8_t> v = {'S', '1', 'a'};
CHECK_THROWS_AS(json::from_ubjson(v), json::parse_error);
CHECK_THROWS_AS(json::from_ubjson(v), json::parse_error&);
CHECK_THROWS_WITH(json::from_ubjson(v), "[json.exception.parse_error.113] parse error at 2: expected a UBJSON string; last byte: 0x31");
}
}
@ -1374,7 +1374,7 @@ TEST_CASE("UBJSON")
SECTION("optimized array: no size following type")
{
std::vector<uint8_t> v = {'[', '$', 'i', 2};
CHECK_THROWS_AS(json::from_ubjson(v), json::parse_error);
CHECK_THROWS_AS(json::from_ubjson(v), json::parse_error&);
CHECK_THROWS_WITH(json::from_ubjson(v), "[json.exception.parse_error.112] parse error at 4: expected '#' after UBJSON type information; last byte: 0x02");
}
}