Satisfy clang-tidy in the new bulk scanner tests

- give the helper lambdas an explicit std::string return type and return
  braced initializer lists (modernize-return-braced-init-list)
- replace the C-style array of test cases with a std::vector
  (modernize-avoid-c-arrays)
- silence pro-type-member-init on the two brace-initialized aggregates;
  default member initializers would stop them being aggregates in C++11

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
Niels Lohmann
2026-08-31 23:25:02 +02:00
committed by GitHub
parent 22d05f5ef5
commit 3f7760ebba
2 changed files with 21 additions and 17 deletions
+13 -11
View File
@@ -313,7 +313,7 @@ TEST_CASE("lexer number fast path")
// full outcome of parsing @a doc, so a mismatch in type, value, or error
// message is caught, not just a mismatch in acceptance
const auto outcome = [](const std::string & doc, bool streaming)
const auto outcome = [](const std::string & doc, bool streaming) -> std::string
{
try
{
@@ -328,7 +328,7 @@ TEST_CASE("lexer number fast path")
}
catch (const json::parse_error& e)
{
return std::string(e.what());
return {e.what()};
}
};
@@ -370,7 +370,7 @@ TEST_CASE("lexer number fast path")
// by a newline is the interesting case, because the byte path reaches the
// newline (which resets the column) and then ungets it.
// returns the parse_error message, or "" if the document parsed
const auto contiguous_error = [](const std::string & doc)
const auto contiguous_error = [](const std::string & doc) -> std::string
{
try
{
@@ -379,11 +379,11 @@ TEST_CASE("lexer number fast path")
}
catch (const json::parse_error& e)
{
return std::string(e.what());
return {e.what()};
}
return std::string();
return {};
};
const auto streaming_error = [](const std::string & doc)
const auto streaming_error = [](const std::string & doc) -> std::string
{
try
{
@@ -393,9 +393,9 @@ TEST_CASE("lexer number fast path")
}
catch (const json::parse_error& e)
{
return std::string(e.what());
return {e.what()};
}
return std::string();
return {};
};
for (const char* bad :
@@ -439,7 +439,7 @@ TEST_CASE("lexer string fast path")
// the full outcome of parsing @a doc: the parsed value, or the exact error
// message, so a mismatch in either is caught. Only usable with exceptions
// on: parsing invalid input aborts when they are off.
const auto outcome = [](const std::string & doc, bool streaming)
const auto outcome = [](const std::string & doc, bool streaming) -> std::string
{
try
{
@@ -457,7 +457,7 @@ TEST_CASE("lexer string fast path")
// as a reported mismatch rather than as an uncaught exception
catch (const json::exception& e)
{
return std::string(e.what());
return {e.what()};
}
};
#endif
@@ -547,7 +547,9 @@ TEST_CASE("lexer string fast path")
{
// The bulk validator must accept exactly what the byte-at-a-time
// scanner accepts, so pin the boundaries of every range it recognizes.
struct utf8_case
// aggregate, only ever brace-initialized below; default member
// initializers would stop it being an aggregate in C++11
struct utf8_case // NOLINT(cppcoreguidelines-pro-type-member-init,hicpp-member-init)
{
std::string sequence;
bool valid;