mirror of
https://github.com/nlohmann/json.git
synced 2026-03-02 07:16:24 +00:00
🚨 add new CI and fix warnings (#2561)
* ⚗️ move CI targets to CMake * ♻️ add target for cpplint * ♻️ add target for self-contained binaries * ♻️ add targets for iwyu and infer * 🔊 add version output * ♻️ add target for oclint * 🚨 fix warnings * ♻️ rename targets * ♻️ use iwyu properly * 🚨 fix warnings * ♻️ use iwyu properly * ♻️ add target for benchmarks * ♻️ add target for CMake flags * 👷 use GitHub Actions * ⚗️ try to install Clang 11 * ⚗️ try to install GCC 11 * ⚗️ try to install Clang 11 * ⚗️ try to install GCC 11 * ⚗️ add clang analyze target * 🔥 remove Google Benchmark * ⬆️ Google Benchmark 1.5.2 * 🔥 use fetchcontent * 🐧 add target to download a Linux version of CMake * 🔨 fix dependency * 🚨 fix includes * 🚨 fix comment * 🔧 adjust flags for GCC 11.0.0 20210110 (experimental) * 🐳 user Docker image to run CI * 🔧 add target for Valgrind * 👷 add target for Valgrind tests * ⚗️ add Dart * ⏪ remove Dart * ⚗️ do not call ctest in test subdirectory * ⚗️ download test data explicitly * ⚗️ only execute Valgrind tests * ⚗️ fix labels * 🔥 remove unneeded jobs * 🔨 cleanup * 🐛 fix OCLint call * ✅ add targets for offline and git-independent tests * ✅ add targets for C++ language versions and reproducible tests * 🔨 clean up * 👷 add CI steps for cppcheck and cpplint * 🚨 fix warnings from Clang-Tidy * 👷 add CI steps for Clang-Tidy * 🚨 fix warnings * 🔧 select proper binary * 🚨 fix warnings * 🚨 suppress some unhelpful warnings * 🚨 fix warnings * 🎨 fix format * 🚨 fix warnings * 👷 add CI steps for Sanitizers * 🚨 fix warnings * ⚡ add optimization to sanitizer build * 🚨 fix warnings * 🚨 add missing header * 🚨 fix warnings * 👷 add CI step for coverage * 👷 add CI steps for disabled exceptions and implicit conversions * 🚨 fix warnings * 👷 add CI steps for checking indentation * 🐛 fix variable use * 💚 fix build * ➖ remove CircleCI * 👷 add CI step for diagnostics * 🚨 fix warning * 🔥 clean Travis
This commit is contained in:
@@ -51,42 +51,42 @@ class SaxCountdown
|
||||
return events_left-- > 0;
|
||||
}
|
||||
|
||||
bool boolean(bool)
|
||||
bool boolean(bool /*unused*/)
|
||||
{
|
||||
return events_left-- > 0;
|
||||
}
|
||||
|
||||
bool number_integer(json::number_integer_t)
|
||||
bool number_integer(json::number_integer_t /*unused*/)
|
||||
{
|
||||
return events_left-- > 0;
|
||||
}
|
||||
|
||||
bool number_unsigned(json::number_unsigned_t)
|
||||
bool number_unsigned(json::number_unsigned_t /*unused*/)
|
||||
{
|
||||
return events_left-- > 0;
|
||||
}
|
||||
|
||||
bool number_float(json::number_float_t, const std::string&)
|
||||
bool number_float(json::number_float_t /*unused*/, const std::string& /*unused*/)
|
||||
{
|
||||
return events_left-- > 0;
|
||||
}
|
||||
|
||||
bool string(std::string&)
|
||||
bool string(std::string& /*unused*/)
|
||||
{
|
||||
return events_left-- > 0;
|
||||
}
|
||||
|
||||
bool binary(std::vector<std::uint8_t>&)
|
||||
bool binary(std::vector<std::uint8_t>& /*unused*/)
|
||||
{
|
||||
return events_left-- > 0;
|
||||
}
|
||||
|
||||
bool start_object(std::size_t)
|
||||
bool start_object(std::size_t /*unused*/)
|
||||
{
|
||||
return events_left-- > 0;
|
||||
}
|
||||
|
||||
bool key(std::string&)
|
||||
bool key(std::string& /*unused*/)
|
||||
{
|
||||
return events_left-- > 0;
|
||||
}
|
||||
@@ -96,7 +96,7 @@ class SaxCountdown
|
||||
return events_left-- > 0;
|
||||
}
|
||||
|
||||
bool start_array(std::size_t)
|
||||
bool start_array(std::size_t /*unused*/)
|
||||
{
|
||||
return events_left-- > 0;
|
||||
}
|
||||
@@ -106,7 +106,7 @@ class SaxCountdown
|
||||
return events_left-- > 0;
|
||||
}
|
||||
|
||||
bool parse_error(std::size_t, const std::string&, const json::exception&)
|
||||
bool parse_error(std::size_t /*unused*/, const std::string& /*unused*/, const json::exception& /*unused*/) // NOLINT(readability-convert-member-functions-to-static)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -114,7 +114,7 @@ class SaxCountdown
|
||||
private:
|
||||
int events_left = 0;
|
||||
};
|
||||
}
|
||||
} // namespace
|
||||
|
||||
TEST_CASE("UBJSON")
|
||||
{
|
||||
@@ -175,16 +175,16 @@ TEST_CASE("UBJSON")
|
||||
{
|
||||
std::vector<int64_t> numbers;
|
||||
numbers.push_back((std::numeric_limits<int64_t>::min)());
|
||||
numbers.push_back(-1000000000000000000ll);
|
||||
numbers.push_back(-100000000000000000ll);
|
||||
numbers.push_back(-10000000000000000ll);
|
||||
numbers.push_back(-1000000000000000ll);
|
||||
numbers.push_back(-100000000000000ll);
|
||||
numbers.push_back(-10000000000000ll);
|
||||
numbers.push_back(-1000000000000ll);
|
||||
numbers.push_back(-100000000000ll);
|
||||
numbers.push_back(-10000000000ll);
|
||||
numbers.push_back(-2147483649ll);
|
||||
numbers.push_back(-1000000000000000000LL);
|
||||
numbers.push_back(-100000000000000000LL);
|
||||
numbers.push_back(-10000000000000000LL);
|
||||
numbers.push_back(-1000000000000000LL);
|
||||
numbers.push_back(-100000000000000LL);
|
||||
numbers.push_back(-10000000000000LL);
|
||||
numbers.push_back(-1000000000000LL);
|
||||
numbers.push_back(-100000000000LL);
|
||||
numbers.push_back(-10000000000LL);
|
||||
numbers.push_back(-2147483649LL);
|
||||
for (auto i : numbers)
|
||||
{
|
||||
CAPTURE(i)
|
||||
@@ -302,7 +302,7 @@ TEST_CASE("UBJSON")
|
||||
|
||||
// check individual bytes
|
||||
CHECK(result[0] == 'I');
|
||||
int16_t restored = static_cast<int16_t>(((result[1] << 8) + result[2]));
|
||||
auto restored = static_cast<int16_t>(((result[1] << 8) + result[2]));
|
||||
CHECK(restored == i);
|
||||
|
||||
// roundtrip
|
||||
@@ -323,7 +323,7 @@ TEST_CASE("UBJSON")
|
||||
|
||||
// check individual bytes
|
||||
CHECK(result[0] == 'I');
|
||||
int16_t restored = static_cast<int16_t>(((result[1] << 8) + result[2]));
|
||||
auto restored = static_cast<int16_t>(((result[1] << 8) + result[2]));
|
||||
CHECK(restored == -9263);
|
||||
|
||||
// roundtrip
|
||||
@@ -455,7 +455,7 @@ TEST_CASE("UBJSON")
|
||||
|
||||
// check individual bytes
|
||||
CHECK(result[0] == 'I');
|
||||
uint16_t restored = static_cast<uint16_t>(static_cast<uint8_t>(result[1]) * 256 + static_cast<uint8_t>(result[2]));
|
||||
auto restored = static_cast<uint16_t>(static_cast<uint8_t>(result[1]) * 256 + static_cast<uint8_t>(result[2]));
|
||||
CHECK(restored == i);
|
||||
|
||||
// roundtrip
|
||||
@@ -583,7 +583,7 @@ TEST_CASE("UBJSON")
|
||||
|
||||
// check individual bytes
|
||||
CHECK(result[0] == 'i');
|
||||
uint8_t restored = static_cast<uint8_t>(result[1]);
|
||||
auto restored = static_cast<uint8_t>(result[1]);
|
||||
CHECK(restored == i);
|
||||
|
||||
// roundtrip
|
||||
@@ -616,7 +616,7 @@ TEST_CASE("UBJSON")
|
||||
|
||||
// check individual bytes
|
||||
CHECK(result[0] == 'U');
|
||||
uint8_t restored = static_cast<uint8_t>(result[1]);
|
||||
auto restored = static_cast<uint8_t>(result[1]);
|
||||
CHECK(restored == i);
|
||||
|
||||
// roundtrip
|
||||
@@ -650,7 +650,7 @@ TEST_CASE("UBJSON")
|
||||
|
||||
// check individual bytes
|
||||
CHECK(result[0] == 'I');
|
||||
uint16_t restored = static_cast<uint16_t>(static_cast<uint8_t>(result[1]) * 256 + static_cast<uint8_t>(result[2]));
|
||||
auto restored = static_cast<uint16_t>(static_cast<uint8_t>(result[1]) * 256 + static_cast<uint8_t>(result[2]));
|
||||
CHECK(restored == i);
|
||||
|
||||
// roundtrip
|
||||
@@ -1535,7 +1535,7 @@ TEST_CASE("UBJSON")
|
||||
{
|
||||
SECTION("size=false type=false")
|
||||
{
|
||||
json j = json::parse("{\"a\": {\"b\": {\"c\": {}}}}");
|
||||
json j = json::parse(R"({"a": {"b": {"c": {}}}})");
|
||||
std::vector<uint8_t> expected =
|
||||
{
|
||||
'{', 'i', 1, 'a', '{', 'i', 1, 'b', '{', 'i', 1, 'c', '{', '}', '}', '}', '}'
|
||||
@@ -1550,7 +1550,7 @@ TEST_CASE("UBJSON")
|
||||
|
||||
SECTION("size=true type=false")
|
||||
{
|
||||
json j = json::parse("{\"a\": {\"b\": {\"c\": {}}}}");
|
||||
json j = json::parse(R"({"a": {"b": {"c": {}}}})");
|
||||
std::vector<uint8_t> expected =
|
||||
{
|
||||
'{', '#', 'i', 1, 'i', 1, 'a', '{', '#', 'i', 1, 'i', 1, 'b', '{', '#', 'i', 1, 'i', 1, 'c', '{', '#', 'i', 0
|
||||
@@ -1565,7 +1565,7 @@ TEST_CASE("UBJSON")
|
||||
|
||||
SECTION("size=true type=true")
|
||||
{
|
||||
json j = json::parse("{\"a\": {\"b\": {\"c\": {}}}}");
|
||||
json j = json::parse(R"({"a": {"b": {"c": {}}}})");
|
||||
std::vector<uint8_t> expected =
|
||||
{
|
||||
'{', '$', '{', '#', 'i', 1, 'i', 1, 'a', '$', '{', '#', 'i', 1, 'i', 1, 'b', '$', '{', '#', 'i', 1, 'i', 1, 'c', '#', 'i', 0
|
||||
@@ -1610,7 +1610,7 @@ TEST_CASE("UBJSON")
|
||||
CHECK_THROWS_AS(_ = json::from_ubjson(v_ubjson), json::out_of_range&);
|
||||
|
||||
json j;
|
||||
nlohmann::detail::json_sax_dom_callback_parser<json> scp(j, [](int, json::parse_event_t, const json&)
|
||||
nlohmann::detail::json_sax_dom_callback_parser<json> scp(j, [](int /*unused*/, json::parse_event_t /*unused*/, const json& /*unused*/)
|
||||
{
|
||||
return true;
|
||||
});
|
||||
@@ -1624,7 +1624,7 @@ TEST_CASE("UBJSON")
|
||||
CHECK_THROWS_AS(_ = json::from_ubjson(v_ubjson), json::out_of_range&);
|
||||
|
||||
json j;
|
||||
nlohmann::detail::json_sax_dom_callback_parser<json> scp(j, [](int, json::parse_event_t, const json&)
|
||||
nlohmann::detail::json_sax_dom_callback_parser<json> scp(j, [](int /*unused*/, json::parse_event_t /*unused*/, const json& /*unused*/)
|
||||
{
|
||||
return true;
|
||||
});
|
||||
@@ -2439,7 +2439,7 @@ TEST_CASE("all UBJSON first bytes")
|
||||
// check that parse_error.112 is only thrown if the
|
||||
// first byte is not in the supported set
|
||||
INFO_WITH_TEMP(e.what());
|
||||
if (std::find(supported.begin(), supported.end(), byte) == supported.end())
|
||||
if (supported.find(byte) == supported.end())
|
||||
{
|
||||
CHECK(e.id == 112);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user