mirror of
https://github.com/red0124/ssp.git
synced 2025-01-23 04:55:20 +01:00
Minor test changes
This commit is contained in:
parent
03870aa1ba
commit
3170cb661c
@ -23,6 +23,24 @@ namespace {
|
||||
}
|
||||
}
|
||||
|
||||
template <typename... Ts>
|
||||
void expect_error_on_command(ss::parser<Ts...>& p,
|
||||
const std::function<void()> command) {
|
||||
if (ss::setup<Ts...>::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<Ts...>::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 <typename... Ts>
|
||||
void expect_error_on_command(ss::parser<Ts...>& p,
|
||||
const std::function<void()> command) {
|
||||
if (ss::setup<Ts...>::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<Ts...>::string_error) {
|
||||
CHECK_FALSE(p.error_msg().empty());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <typename... Ts>
|
||||
void test_unterminated_line_impl(const std::vector<std::string>& lines,
|
||||
size_t bad_line) {
|
||||
|
@ -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<std::string> generate_csv_data(const std::vector<field>& data,
|
||||
return output;
|
||||
}
|
||||
|
||||
void write_to_file(const std::vector<std::string>& data,
|
||||
[[maybe_unused]] void write_to_file(const std::vector<std::string>& 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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user