Fix develop CI: GCC 4.8, Clang 3.4 and clang-tidy errors (#6100)
* Fix develop CI: GCC 4.8, Clang 3.4 and clang-tidy errors - unit-json_patch.cpp: move multi-line raw strings out of CHECK(), which GCC 4.8 cannot parse inside a macro argument - unit-recursion_depth_limit.cpp: value-initialize the const std::hash (Clang 3.4 rejects default initialization of a const object) - json_view: silence modernize-use-transparent-functors (std::less<> is C++14), bugprone-suspicious-stringview-data-usage (the length comes from the node) and the deliberate use-after-clear() / owning-memory hits in unit-json_view_builder.cpp; use a raw string literal there Signed-off-by: Niels Lohmann <mail@nlohmann.me> * Fix clang-tidy errors in the std::u8string tests Test the lvalue path with the const original instead of a mutable copy and the rvalue path with a temporary (misc-const-correctness), and mark the intentional char8_t array with NOLINT (avoid-c-arrays). Signed-off-by: Niels Lohmann <mail@nlohmann.me> --------- Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
1 parent
cdfb130fa6
commit
2755952d36
7 files changed
+25
-16
No files matched your search
@@ -916,14 +916,15 @@ TEST_CASE("json_view document_data::holds() (the debug check of read())")
|
||||
|
||||
SECTION("owned text")
|
||||
{
|
||||
d->owned = "{\"a\":\"some text that does not fit a short string\"}";
|
||||
d->owned = R"({"a":"some text that does not fit a short string"})";
|
||||
const char* const b = d->owned.data();
|
||||
CHECK(d->holds(b, 1));
|
||||
CHECK(d->holds(b + 5, 3));
|
||||
CHECK(d->holds(b + d->owned.size() - 1, 1));
|
||||
// also after clear(), which keeps the buffer that the next parse writes
|
||||
d->owned.clear();
|
||||
CHECK(d->holds(b, 4));
|
||||
// (b is only compared with the buffer, never read)
|
||||
CHECK(d->holds(b, 4)); // NOLINT(clang-analyzer-cplusplus.InnerPointer)
|
||||
CHECK(!d->holds(other.data(), other.size()));
|
||||
CHECK(!d->holds(b, 0));
|
||||
}
|
||||
@@ -946,7 +947,7 @@ TEST_CASE("json_view document_data::holds() (the debug check of read())")
|
||||
{
|
||||
d->edits.reset(new document_data::edit_state()); // NOLINT(cppcoreguidelines-owning-memory)
|
||||
CHECK(!d->holds(other.data(), other.size()));
|
||||
d->edits->texts.emplace_back(new char[16]); // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
|
||||
d->edits->texts.emplace_back(new char[16]); // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays,cppcoreguidelines-owning-memory)
|
||||
d->edits->text_cap = 16;
|
||||
CHECK(d->holds(d->edits->texts.back().get() + 3, 3));
|
||||
CHECK(!d->holds(other.data(), other.size()));
|
||||
|
||||
Reference in new issue
Block a user