mirror of
https://github.com/nlohmann/json.git
synced 2026-02-17 09:03:58 +00:00
* handle nullptr explicitly Signed-off-by: Nikhil <nikhilreddydev@gmail.com> * add test Signed-off-by: Nikhil <nikhilreddydev@gmail.com> * make amalgamate Signed-off-by: Nikhil <nikhilreddydev@gmail.com> * Fix formatting Signed-off-by: Nikhil <nikhilreddydev@gmail.com> * move sax parse test to relevant unit test file Signed-off-by: Nikhil <nikhilreddydev@gmail.com> * extend exceptions.md to include other_error.502 Signed-off-by: Nikhil <nikhilreddydev@gmail.com> * Better exception messages Signed-off-by: Nikhil <nikhilreddydev@gmail.com> * link sax_parse function Signed-off-by: Nikhil <nikhilreddydev@gmail.com> * fix string Signed-off-by: Nikhil <nikhilreddydev@gmail.com> * amalgamate Signed-off-by: Nikhil <nikhilreddydev@gmail.com> * fix clang-tidy checks Signed-off-by: Nikhil <nikhilreddydev@gmail.com> * cover valid handler with no throw Signed-off-by: Nikhil <nikhilreddydev@gmail.com> * Add tests for other two overloads Signed-off-by: Nikhil <nikhilreddydev@gmail.com> * cover overload with valid sax handler Signed-off-by: Nikhil <nikhilreddydev@gmail.com> * pass an rvalue Signed-off-by: Nikhil <nikhilreddydev@gmail.com> * ignore -Wtautological-pointer-compare Signed-off-by: Nikhil <nikhilreddydev@gmail.com> * ignore clang-analyzer-core.NonNullParamChecker Signed-off-by: Nikhil <nikhilreddydev@gmail.com> * ignore gcc -Wnonnull-compare Signed-off-by: Nikhil <nikhilreddydev@gmail.com> * ignore undefined-behaviour-sanitizer Signed-off-by: Nikhil <nikhilreddydev@gmail.com> * nest directives to ignore sanitizer errors Signed-off-by: Nikhil <nikhilreddydev@gmail.com> * use elif Signed-off-by: Nikhil <nikhilreddydev@gmail.com> --------- Signed-off-by: Nikhil <nikhilreddydev@gmail.com>
This commit is contained in:
@@ -1644,6 +1644,33 @@ TEST_CASE("parser class")
|
||||
|
||||
SECTION("SAX parser")
|
||||
{
|
||||
SECTION("null sax handler")
|
||||
{
|
||||
# if defined(__has_feature)
|
||||
#if !__has_feature(undefined_behavior_sanitizer)
|
||||
const std::string s = "some_string";
|
||||
SaxCountdown* p = nullptr;
|
||||
CHECK_THROWS_WITH_AS(json::sax_parse(s, p), "[json.exception.other_error.502] SAX handler must not be null", json::other_error&); // NOLINT(clang-analyzer-core.NonNullParamChecker)
|
||||
CHECK_THROWS_WITH_AS(json::sax_parse(s.begin(), s.end(), p), "[json.exception.other_error.502] SAX handler must not be null", json::other_error&); // NOLINT(clang-analyzer-core.NonNullParamChecker)
|
||||
CHECK_THROWS_WITH_AS(json::sax_parse(nlohmann::detail::span_input_adapter(s.c_str(), s.size()), p), "[json.exception.other_error.502] SAX handler must not be null", json::other_error&); // NOLINT(clang-analyzer-core.NonNullParamChecker)
|
||||
#endif
|
||||
#else
|
||||
const std::string s = "some_string";
|
||||
SaxCountdown* p = nullptr;
|
||||
CHECK_THROWS_WITH_AS(json::sax_parse(s, p), "[json.exception.other_error.502] SAX handler must not be null", json::other_error&); // NOLINT(clang-analyzer-core.NonNullParamChecker)
|
||||
CHECK_THROWS_WITH_AS(json::sax_parse(s.begin(), s.end(), p), "[json.exception.other_error.502] SAX handler must not be null", json::other_error&); // NOLINT(clang-analyzer-core.NonNullParamChecker)
|
||||
CHECK_THROWS_WITH_AS(json::sax_parse(nlohmann::detail::span_input_adapter(s.c_str(), s.size()), p), "[json.exception.other_error.502] SAX handler must not be null", json::other_error&); // NOLINT(clang-analyzer-core.NonNullParamChecker)
|
||||
#endif
|
||||
}
|
||||
|
||||
SECTION("valid sax handler")
|
||||
{
|
||||
const std::string str = "some_string";
|
||||
SaxCountdown s(1);
|
||||
CHECK(json::sax_parse(str, &s) == false);
|
||||
CHECK(json::sax_parse(nlohmann::detail::span_input_adapter(str.c_str(), str.size()), &s) == false);
|
||||
}
|
||||
|
||||
SECTION("} without value")
|
||||
{
|
||||
SaxCountdown s(1);
|
||||
|
||||
Reference in New Issue
Block a user