From 3170cb661c0e3ad815e7a05a8cfb1838a7434611 Mon Sep 17 00:00:00 2001 From: ado Date: Sat, 5 Aug 2023 13:49:10 +0200 Subject: [PATCH] Minor test changes --- test/test_parser.cpp | 36 ++++++++++++++++++------------------ test/test_parser2.hpp | 5 ++--- 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/test/test_parser.cpp b/test/test_parser.cpp index 151414c..bc0cc43 100644 --- a/test/test_parser.cpp +++ b/test/test_parser.cpp @@ -23,6 +23,24 @@ namespace { } } +template +void expect_error_on_command(ss::parser& p, + const std::function command) { + if (ss::setup::throw_on_error) { + try { + command(); + } catch (const std::exception& e) { + CHECK_FALSE(std::string{e.what()}.empty()); + } + } else { + command(); + CHECK(!p.valid()); + if constexpr (ss::setup::string_error) { + CHECK_FALSE(p.error_msg().empty()); + } + } +} + void update_if_crlf(std::string& s) { #ifdef _WIN32 replace_all(s, "\r\n", "\n"); @@ -881,24 +899,6 @@ TEST_CASE("parser test multiline restricted") { CHECK_EQ(i, data); } -template -void expect_error_on_command(ss::parser& p, - const std::function command) { - if (ss::setup::throw_on_error) { - try { - command(); - } catch (const std::exception& e) { - CHECK_FALSE(std::string{e.what()}.empty()); - } - } else { - command(); - CHECK(!p.valid()); - if constexpr (ss::setup::string_error) { - CHECK_FALSE(p.error_msg().empty()); - } - } -} - template void test_unterminated_line_impl(const std::vector& lines, size_t bad_line) { diff --git a/test/test_parser2.hpp b/test/test_parser2.hpp index 0706c1b..8b7dc47 100644 --- a/test/test_parser2.hpp +++ b/test/test_parser2.hpp @@ -120,7 +120,7 @@ column make_column(const std::string& input_header, return c; } -void replace_all2(std::string& s, const std::string& old_value, +[[maybe_unused] void replace_all2(std::string& s, const std::string& old_value, const std::string& new_value) { for (size_t i = 0; i < 999; ++i) { size_t pos = s.find(old_value); @@ -256,7 +256,7 @@ std::vector generate_csv_data(const std::vector& data, return output; } -void write_to_file(const std::vector& data, +[[maybe_unused]] void write_to_file(const std::vector& data, const std::string& delim, const std::string& file_name) { std::ofstream out{file_name, std::ios_base::app}; std::string line; @@ -651,4 +651,3 @@ TEST_CASE("parser test various cases version 2 segment 1") { } #endif -