1
0
mirror of https://github.com/nlohmann/json.git synced 2025-07-25 13:41:56 +03:00

💚 improved test coverage

This commit is contained in:
Niels Lohmann
2018-03-10 11:24:00 +01:00
parent 6399cd3039
commit 149d2fd09c
3 changed files with 38 additions and 49 deletions

View File

@ -176,7 +176,18 @@ bool accept_helper(const std::string& s)
CHECK_NOTHROW(json::sax_parse(s, &el));
CHECK(json::parser(nlohmann::detail::input_adapter(s)).accept(false) == not el.errored);
// 5. return result
// 5. parse with simple callback
json::parser_callback_t cb = [](int, json::parse_event_t, json&)
{
return true;
};
json j_cb = json::parse(s, cb, false);
const bool ok_noexcept_cb = not j_cb.is_discarded();
// 6. check if this approach came to the same result
CHECK(ok_noexcept == ok_noexcept_cb);
// 7. return result
return ok_accept;
}