Fix the red CI on develop (json_view pointer tokens, bson, from_json tests, Infer, IWYU) (#5942)
* json_view: pointer tokens that cannot be array indices create objects editable_document::set() chose an array for a null parent whenever the token consisted of digits, so "01" threw parse_error.106 and the empty token threw, while basic_json::operator[](json_pointer) has created an object for such tokens since #5358. This broke unit-json_view_edit_values on develop. Use the same RFC 6901 array index test as basic_json. Also re-indent the unflatten test that the astyle check flagged. Signed-off-by: Niels Lohmann <mail@nlohmann.me> * Fix the other red jobs on develop - unit-bson: initialize recorder::events in its declaration (-Weffc++) - unit-json_view_from_json: suppress -Wexit-time-destructors for the serialize-enum tables and -Wfloat-equal for same() - unit-pointer_access: @infer-ignore NULLPTR_DEREFERENCE for the dereferences after get_ptr() that Infer reports - json_view.hpp: IWYU no_include for the detail headers that the view code uses through nlohmann/json.hpp Signed-off-by: Niels Lohmann <mail@nlohmann.me> * Fix GCC warnings in the json_view from_json test GCC (-Weffc++, -Wfloat-equal) rejected unit-json_view_from_json.cpp (ci_test_standards_gcc (20)): initialize the members of shape and with_names, and suppress -Wfloat-equal for GCC like for clang. Signed-off-by: Niels Lohmann <mail@nlohmann.me> --------- Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
1 parent
21ec9bd801
commit
2bb2feeef4
6 files changed
+42
-14
No files matched your search
@@ -54,9 +54,11 @@
|
||||
// IWYU pragma: no_include <version>
|
||||
// IWYU pragma: no_include "nlohmann/detail/abi_config.hpp"
|
||||
// IWYU pragma: no_include "nlohmann/detail/abi_macros.hpp"
|
||||
// IWYU pragma: no_include "nlohmann/detail/conversions/from_json.hpp"
|
||||
// IWYU pragma: no_include "nlohmann/detail/input/input_adapters.hpp"
|
||||
// IWYU pragma: no_include "nlohmann/detail/json_pointer.hpp"
|
||||
// IWYU pragma: no_include "nlohmann/detail/meta/cpp_future.hpp"
|
||||
// IWYU pragma: no_include "nlohmann/detail/meta/type_traits.hpp"
|
||||
// IWYU pragma: no_include "nlohmann/detail/string_concat.hpp"
|
||||
// IWYU pragma: no_include "nlohmann/detail/value_t.hpp"
|
||||
// IWYU pragma: no_include "nlohmann/json.hpp"
|
||||
@@ -1313,7 +1315,7 @@ class basic_json_document
|
||||
/// member is set (added if missing), an array element assigned, and "-"
|
||||
/// or the size of the array appends. A null parent becomes what
|
||||
/// basic_json's operator[](json_pointer) makes of it: an array for "-"
|
||||
/// and for digits (padded with nulls up to the index), an object otherwise.
|
||||
/// and for array indices (padded with nulls up to the index), an object otherwise.
|
||||
template<typename V>
|
||||
view_type set(const json_pointer& ptr, V&& value)
|
||||
{
|
||||
@@ -1329,7 +1331,11 @@ class basic_json_document
|
||||
{
|
||||
return push_back(parent, std::forward<V>(value));
|
||||
}
|
||||
const bool digits = std::all_of(token.begin(), token.end(), [](const char c)
|
||||
// (a token that cannot be an array index, such as "01" or "", names an
|
||||
// object member, as in basic_json)
|
||||
const bool digits = !token.empty()
|
||||
&& (token.size() == 1 || token[0] != '0')
|
||||
&& std::all_of(token.begin(), token.end(), [](const char c)
|
||||
{
|
||||
return c >= '0' && c <= '9';
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user