Fix CI: unused parameter without exceptions, cpplint, BUILD.bazel
- json_sax_error_reporter::parse_error: mark the exception unused, as JSON_THROW does not use it with JSON_NOEXCEPTION - unit-contiguous_parser.cpp: compare the exceptions of both paths only when exceptions are enabled (invalid input aborted the test otherwise) - silence cpplint's readability/braces false positives on the if statements inside the parser's macros - add contiguous_parser.hpp to BUILD.bazel Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
4 files changed
+18
-14
No files matched your search
@@ -86,10 +86,10 @@ std::string describe_value(const Json& j, int depth = 0)
|
||||
return out;
|
||||
}
|
||||
|
||||
#if !defined(JSON_NOEXCEPTION)
|
||||
template<typename Json, typename Parse>
|
||||
std::string outcome(Parse parse)
|
||||
{
|
||||
#if !defined(JSON_NOEXCEPTION)
|
||||
try
|
||||
{
|
||||
return describe_value(parse());
|
||||
@@ -98,10 +98,8 @@ std::string outcome(Parse parse)
|
||||
{
|
||||
return std::string("exception: ") + e.what();
|
||||
}
|
||||
#else
|
||||
return describe_value(parse());
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
/// every SAX event with its values, the text of float tokens, and the parse
|
||||
/// error with its position, token and message; returns false after
|
||||
@@ -220,6 +218,8 @@ void check_same(const std::string& text)
|
||||
CAPTURE(text)
|
||||
const std::list<char> bytes(text.begin(), text.end());
|
||||
|
||||
#if !defined(JSON_NOEXCEPTION)
|
||||
// with exceptions: the value, or the same exception for both
|
||||
const std::string contiguous = outcome<Json>([&]
|
||||
{
|
||||
return Json::parse(text);
|
||||
@@ -229,6 +229,7 @@ void check_same(const std::string& text)
|
||||
return Json::parse(bytes.begin(), bytes.end());
|
||||
});
|
||||
CHECK(contiguous == byte_path);
|
||||
#endif
|
||||
|
||||
// without exceptions: the value, or discarded for both
|
||||
const Json c = Json::parse(text, nullptr, false);
|
||||
|
||||
Reference in new issue
Block a user