Add [[nodiscard]] where fitting, update unit tests

This commit is contained in:
ado
2024-03-13 23:31:19 +01:00
parent 809939d0e2
commit 77a6373e9b
24 changed files with 417 additions and 365 deletions

View File

@@ -1,17 +1,17 @@
#include "test_helpers.hpp"
#include <algorithm>
#include <ss/converter.hpp>
TEST_CASE("converter test split") {
ss::converter c;
for (const auto& [s, expected, delim] :
// clang-format off
{std::make_tuple("a,b,c,d", std::vector{"a", "b", "c", "d"}, ","),
{"", {}, " "},
{" x x x x | x ", {" x x x x ", " x "}, "|"},
{"a::b::c::d", {"a", "b", "c", "d"}, "::"},
{"x\t-\ty", {"x", "y"}, "\t-\t"},
{"x", {"x"}, ","}} // clang-format on
{std::make_tuple("a,b,c,d", std::vector{"a", "b", "c", "d"}, ","),
{"", {}, " "},
{" x x x x | x ", {" x x x x ", " x "}, "|"},
{"a::b::c::d", {"a", "b", "c", "d"}, "::"},
{"x\t-\ty", {"x", "y"}, "\t-\t"},
{"x", {"x"}, ","}}
// clang-format on
) {
auto split = c.split(s, delim);
CHECK_EQ(split.size(), expected.size());
@@ -278,37 +278,38 @@ TEST_CASE_TEMPLATE("converter test valid conversions with exceptions", T, int,
TEST_CASE_TEMPLATE("converter test invalid conversions", T, int, ss::uint8) {
ss::converter c;
c.convert<T>("");
std::ignore = c.convert<T>("");
REQUIRE_FALSE(c.valid());
c.convert<T>("1", "");
std::ignore = c.convert<T>("1", "");
REQUIRE_FALSE(c.valid());
c.convert<T>("10", "");
std::ignore = c.convert<T>("10", "");
REQUIRE_FALSE(c.valid());
c.convert<T, void>("");
std::ignore = c.convert<T, void>("");
REQUIRE_FALSE(c.valid());
c.convert<T, void>(",junk");
std::ignore = c.convert<T, void>(",junk");
REQUIRE_FALSE(c.valid());
c.convert<void, T>("junk,");
std::ignore = c.convert<void, T>("junk,");
REQUIRE_FALSE(c.valid());
c.convert<T>("x");
std::ignore = c.convert<T>("x");
REQUIRE_FALSE(c.valid());
c.convert<T, void>("x");
std::ignore = c.convert<T, void>("x");
REQUIRE_FALSE(c.valid());
c.convert<T, void>("x,junk");
std::ignore = c.convert<T, void>("x,junk");
REQUIRE_FALSE(c.valid());
c.convert<void, T>("junk,x");
std::ignore = c.convert<void, T>("junk,x");
REQUIRE_FALSE(c.valid());
c.convert<void, std::variant<T, double>, double>("junk;.5.5;6", ";");
std::ignore =
c.convert<void, std::variant<T, double>, double>("junk;.5.5;6", ";");
REQUIRE_FALSE(c.valid());
}
@@ -316,34 +317,36 @@ TEST_CASE_TEMPLATE("converter test invalid conversions with exceptions", T, int,
ss::uint8) {
ss::converter<ss::throw_on_error> c;
REQUIRE_EXCEPTION(c.convert<T>(""));
REQUIRE_EXCEPTION(c.convert<T>("1", ""));
REQUIRE_EXCEPTION(c.convert<T>("10", ""));
REQUIRE_EXCEPTION(c.convert<T, void>(""));
REQUIRE_EXCEPTION(c.convert<T, void>(",junk"));
REQUIRE_EXCEPTION(c.convert<void, T>("junk,"));
REQUIRE_EXCEPTION(c.convert<T>("x"));
REQUIRE_EXCEPTION(c.convert<T, void>("x"));
REQUIRE_EXCEPTION(c.convert<T, void>("x,junk"));
REQUIRE_EXCEPTION(c.convert<void, T>("junk,x"));
REQUIRE_EXCEPTION(std::ignore = c.convert<T>(""));
REQUIRE_EXCEPTION(std::ignore = c.convert<T>("1", ""));
REQUIRE_EXCEPTION(std::ignore = c.convert<T>("10", ""));
REQUIRE_EXCEPTION(std::ignore = c.convert<T, void>(""));
REQUIRE_EXCEPTION(std::ignore = c.convert<T, void>(",junk"));
REQUIRE_EXCEPTION(std::ignore = c.convert<void, T>("junk,"));
REQUIRE_EXCEPTION(std::ignore = c.convert<T>("x"));
REQUIRE_EXCEPTION(std::ignore = c.convert<T, void>("x"));
REQUIRE_EXCEPTION(std::ignore = c.convert<T, void>("x,junk"));
REQUIRE_EXCEPTION(std::ignore = c.convert<void, T>("junk,x"));
REQUIRE_EXCEPTION(
c.convert<void, std::variant<T, double>, double>("junk;.5.5;6", ";"));
std::ignore =
c.convert<void, std::variant<T, double>, double>("junk;.5.5;6",
";"));
}
TEST_CASE_TEMPLATE("converter test ss:ax restriction (all except)", T, int,
ss::uint8) {
ss::converter c;
c.convert<ss::ax<T, 0>>("0");
std::ignore = c.convert<ss::ax<T, 0>>("0");
REQUIRE_FALSE(c.valid());
c.convert<ss::ax<T, 0, 1, 2>>("1");
std::ignore = c.convert<ss::ax<T, 0, 1, 2>>("1");
REQUIRE_FALSE(c.valid());
c.convert<void, char, ss::ax<T, 0, 1, 2>>("junk,c,1");
std::ignore = c.convert<void, char, ss::ax<T, 0, 1, 2>>("junk,c,1");
REQUIRE_FALSE(c.valid());
c.convert<ss::ax<T, 1>, char>("1,c");
std::ignore = c.convert<ss::ax<T, 1>, char>("1,c");
REQUIRE_FALSE(c.valid());
{
T tup = c.convert<ss::ax<T, 1>>("3");
@@ -367,10 +370,11 @@ TEST_CASE_TEMPLATE(
ss::uint8) {
ss::converter<ss::throw_on_error> c;
REQUIRE_EXCEPTION(c.convert<ss::ax<T, 0>>("0"));
REQUIRE_EXCEPTION(c.convert<ss::ax<T, 0, 1, 2>>("1"));
REQUIRE_EXCEPTION(c.convert<void, char, ss::ax<T, 0, 1, 2>>("junk,c,1"));
REQUIRE_EXCEPTION(c.convert<ss::ax<T, 1>, char>("1,c"));
REQUIRE_EXCEPTION(std::ignore = c.convert<ss::ax<T, 0>>("0"));
REQUIRE_EXCEPTION(std::ignore = c.convert<ss::ax<T, 0, 1, 2>>("1"));
REQUIRE_EXCEPTION(
std::ignore = c.convert<void, char, ss::ax<T, 0, 1, 2>>("junk,c,1"));
REQUIRE_EXCEPTION(std::ignore = c.convert<ss::ax<T, 1>, char>("1,c"));
try {
{
@@ -393,13 +397,13 @@ TEST_CASE_TEMPLATE(
TEST_CASE("converter test ss:nx restriction (none except)") {
ss::converter c;
c.convert<ss::nx<int, 1>>("3");
std::ignore = c.convert<ss::nx<int, 1>>("3");
REQUIRE_FALSE(c.valid());
c.convert<char, ss::nx<int, 1, 2, 69>>("c,3");
std::ignore = c.convert<char, ss::nx<int, 1, 2, 69>>("c,3");
REQUIRE_FALSE(c.valid());
c.convert<ss::nx<int, 1>, char>("3,c");
std::ignore = c.convert<ss::nx<int, 1>, char>("3,c");
REQUIRE_FALSE(c.valid());
{
@@ -427,9 +431,10 @@ TEST_CASE("converter test ss:nx restriction (none except)") {
TEST_CASE("converter test ss:nx restriction (none except) with exceptions") {
ss::converter<ss::throw_on_error> c;
REQUIRE_EXCEPTION(c.convert<ss::nx<int, 1>>("3"));
REQUIRE_EXCEPTION(c.convert<char, ss::nx<int, 1, 2, 69>>("c,3"));
REQUIRE_EXCEPTION(c.convert<ss::nx<int, 1>, char>("3,c"));
REQUIRE_EXCEPTION(std::ignore = c.convert<ss::nx<int, 1>>("3"));
REQUIRE_EXCEPTION(std::ignore =
c.convert<char, ss::nx<int, 1, 2, 69>>("c,3"));
REQUIRE_EXCEPTION(std::ignore = c.convert<ss::nx<int, 1>, char>("3,c"));
try {
{
@@ -461,13 +466,13 @@ TEST_CASE_TEMPLATE("converter test ss:ir restriction (in range)", T, int,
ss::uint8) {
ss::converter c;
c.convert<ss::ir<T, 0, 2>>("3");
std::ignore = c.convert<ss::ir<T, 0, 2>>("3");
REQUIRE_FALSE(c.valid());
c.convert<char, ss::ir<T, 4, 69>>("c,3");
std::ignore = c.convert<char, ss::ir<T, 4, 69>>("c,3");
REQUIRE_FALSE(c.valid());
c.convert<ss::ir<T, 1, 2>, char>("3,c");
std::ignore = c.convert<ss::ir<T, 1, 2>, char>("3,c");
REQUIRE_FALSE(c.valid());
{
@@ -497,9 +502,9 @@ TEST_CASE_TEMPLATE(
ss::uint8) {
ss::converter<ss::throw_on_error> c;
REQUIRE_EXCEPTION(c.convert<ss::ir<T, 0, 2>>("3"));
REQUIRE_EXCEPTION(c.convert<char, ss::ir<T, 4, 69>>("c,3"));
REQUIRE_EXCEPTION(c.convert<ss::ir<T, 1, 2>, char>("3,c"));
REQUIRE_EXCEPTION(std::ignore = c.convert<ss::ir<T, 0, 2>>("3"));
REQUIRE_EXCEPTION(std::ignore = c.convert<char, ss::ir<T, 4, 69>>("c,3"));
REQUIRE_EXCEPTION(std::ignore = c.convert<ss::ir<T, 1, 2>, char>("3,c"));
try {
{
@@ -530,16 +535,16 @@ TEST_CASE_TEMPLATE(
TEST_CASE("converter test ss:oor restriction (out of range)") {
ss::converter c;
c.convert<ss::oor<int, 1, 5>>("3");
std::ignore = c.convert<ss::oor<int, 1, 5>>("3");
REQUIRE_FALSE(c.valid());
c.convert<ss::oor<int, 0, 2>>("2");
std::ignore = c.convert<ss::oor<int, 0, 2>>("2");
REQUIRE_FALSE(c.valid());
c.convert<char, ss::oor<int, 0, 1>, void>("c,1,junk");
std::ignore = c.convert<char, ss::oor<int, 0, 1>, void>("c,1,junk");
REQUIRE_FALSE(c.valid());
c.convert<ss::oor<int, 1, 20>, char>("1,c");
std::ignore = c.convert<ss::oor<int, 1, 20>, char>("1,c");
REQUIRE_FALSE(c.valid());
{
@@ -564,10 +569,12 @@ TEST_CASE("converter test ss:oor restriction (out of range)") {
TEST_CASE("converter test ss:oor restriction (out of range) with exceptions") {
ss::converter<ss::throw_on_error> c;
REQUIRE_EXCEPTION(c.convert<ss::oor<int, 1, 5>>("3"));
REQUIRE_EXCEPTION(c.convert<ss::oor<int, 0, 2>>("2"));
REQUIRE_EXCEPTION(c.convert<char, ss::oor<int, 0, 1>, void>("c,1,junk"));
REQUIRE_EXCEPTION(c.convert<ss::oor<int, 1, 20>, char>("1,c"));
REQUIRE_EXCEPTION(std::ignore = c.convert<ss::oor<int, 1, 5>>("3"));
REQUIRE_EXCEPTION(std::ignore = c.convert<ss::oor<int, 0, 2>>("2"));
REQUIRE_EXCEPTION(
std::ignore = c.convert<char, ss::oor<int, 0, 1>, void>("c,1,junk"));
REQUIRE_EXCEPTION(std::ignore =
c.convert<ss::oor<int, 1, 20>, char>("1,c"));
try {
{
@@ -608,19 +615,19 @@ inline bool ss::extract(const char* begin, const char* end,
TEST_CASE("converter test ss:ne restriction (not empty)") {
ss::converter c;
c.convert<ss::ne<std::string>>("");
std::ignore = c.convert<ss::ne<std::string>>("");
REQUIRE_FALSE(c.valid());
c.convert<int, ss::ne<std::string>>("3,");
std::ignore = c.convert<int, ss::ne<std::string>>("3,");
REQUIRE_FALSE(c.valid());
c.convert<ss::ne<std::string>, int>(",3");
std::ignore = c.convert<ss::ne<std::string>, int>(",3");
REQUIRE_FALSE(c.valid());
c.convert<void, ss::ne<std::string>, int>("junk,,3");
std::ignore = c.convert<void, ss::ne<std::string>, int>("junk,,3");
REQUIRE_FALSE(c.valid());
c.convert<ss::ne<std::vector<int>>>("");
std::ignore = c.convert<ss::ne<std::vector<int>>>("");
REQUIRE_FALSE(c.valid());
{
@@ -643,11 +650,12 @@ TEST_CASE("converter test ss:ne restriction (not empty)") {
TEST_CASE("converter test ss:ne restriction (not empty) with exceptions") {
ss::converter<ss::throw_on_error> c;
REQUIRE_EXCEPTION(c.convert<ss::ne<std::string>>(""));
REQUIRE_EXCEPTION(c.convert<int, ss::ne<std::string>>("3,"));
REQUIRE_EXCEPTION(c.convert<ss::ne<std::string>, int>(",3"));
REQUIRE_EXCEPTION(c.convert<void, ss::ne<std::string>, int>("junk,,3"));
REQUIRE_EXCEPTION(c.convert<ss::ne<std::vector<int>>>(""));
REQUIRE_EXCEPTION(std::ignore = c.convert<ss::ne<std::string>>(""));
REQUIRE_EXCEPTION(std::ignore = c.convert<int, ss::ne<std::string>>("3,"));
REQUIRE_EXCEPTION(std::ignore = c.convert<ss::ne<std::string>, int>(",3"));
REQUIRE_EXCEPTION(std::ignore =
c.convert<void, ss::ne<std::string>, int>("junk,,3"));
REQUIRE_EXCEPTION(std::ignore = c.convert<ss::ne<std::vector<int>>>(""));
try {
{
@@ -675,22 +683,22 @@ TEST_CASE(
"converter test ss:lt ss::lte ss::gt ss::gte restriction (in range)") {
ss::converter c;
c.convert<ss::lt<int, 3>>("3");
std::ignore = c.convert<ss::lt<int, 3>>("3");
REQUIRE_FALSE(c.valid());
c.convert<ss::lt<int, 2>>("3");
std::ignore = c.convert<ss::lt<int, 2>>("3");
REQUIRE_FALSE(c.valid());
c.convert<ss::gt<int, 3>>("3");
std::ignore = c.convert<ss::gt<int, 3>>("3");
REQUIRE_FALSE(c.valid());
c.convert<ss::gt<int, 4>>("3");
std::ignore = c.convert<ss::gt<int, 4>>("3");
REQUIRE_FALSE(c.valid());
c.convert<ss::lte<int, 2>>("3");
std::ignore = c.convert<ss::lte<int, 2>>("3");
REQUIRE_FALSE(c.valid());
c.convert<ss::gte<int, 4>>("3");
std::ignore = c.convert<ss::gte<int, 4>>("3");
REQUIRE_FALSE(c.valid());
{
@@ -734,12 +742,12 @@ TEST_CASE("converter test ss:lt ss::lte ss::gt ss::gte restriction (in range) "
"with exception") {
ss::converter<ss::throw_on_error> c;
REQUIRE_EXCEPTION(c.convert<ss::lt<int, 3>>("3"));
REQUIRE_EXCEPTION(c.convert<ss::lt<int, 2>>("3"));
REQUIRE_EXCEPTION(c.convert<ss::gt<int, 3>>("3"));
REQUIRE_EXCEPTION(c.convert<ss::gt<int, 4>>("3"));
REQUIRE_EXCEPTION(c.convert<ss::lte<int, 2>>("3"));
REQUIRE_EXCEPTION(c.convert<ss::gte<int, 4>>("3"));
REQUIRE_EXCEPTION(std::ignore = c.convert<ss::lt<int, 3>>("3"));
REQUIRE_EXCEPTION(std::ignore = c.convert<ss::lt<int, 2>>("3"));
REQUIRE_EXCEPTION(std::ignore = c.convert<ss::gt<int, 3>>("3"));
REQUIRE_EXCEPTION(std::ignore = c.convert<ss::gt<int, 4>>("3"));
REQUIRE_EXCEPTION(std::ignore = c.convert<ss::lte<int, 2>>("3"));
REQUIRE_EXCEPTION(std::ignore = c.convert<ss::gte<int, 4>>("3"));
try {
{
@@ -784,14 +792,14 @@ TEST_CASE("converter test ss:lt ss::lte ss::gt ss::gte restriction (in range) "
TEST_CASE("converter test error mode") {
ss::converter<ss::string_error> c;
c.convert<int>("junk");
std::ignore = c.convert<int>("junk");
CHECK_FALSE(c.valid());
CHECK_FALSE(c.error_msg().empty());
}
TEST_CASE("converter test throw on error mode") {
ss::converter<ss::throw_on_error> c;
REQUIRE_EXCEPTION(c.convert<int>("junk"));
REQUIRE_EXCEPTION(std::ignore = c.convert<int>("junk"));
}
TEST_CASE("converter test converter with quotes spacing and escaping") {
@@ -908,7 +916,7 @@ TEST_CASE("converter test invalid split conversions") {
{
// mismatched quote
c.convert<std::string, std::string, double, char>(
std::ignore = c.convert<std::string, std::string, double, char>(
buff(R"( "just , some , "12.3","a" )"));
CHECK_FALSE(c.valid());
CHECK_FALSE(c.unterminated_quote());
@@ -917,7 +925,7 @@ TEST_CASE("converter test invalid split conversions") {
{
// unterminated quote
c.convert<std::string, std::string, double, std::string>(
std::ignore = c.convert<std::string, std::string, double, std::string>(
buff(R"( ju\,st , "so,me" , 12.34 , "str""ings)"));
CHECK_FALSE(c.valid());
CHECK(c.unterminated_quote());
@@ -926,7 +934,7 @@ TEST_CASE("converter test invalid split conversions") {
{
// unterminated escape
c.convert<std::string, std::string, double, std::string>(
std::ignore = c.convert<std::string, std::string, double, std::string>(
buff(R"(just,some,2,strings\)"));
CHECK_FALSE(c.valid());
CHECK_FALSE(c.unterminated_quote());
@@ -935,7 +943,7 @@ TEST_CASE("converter test invalid split conversions") {
{
// unterminated escape while quoting
c.convert<std::string, std::string, double, std::string>(
std::ignore = c.convert<std::string, std::string, double, std::string>(
buff(R"(just,some,2,"strings\)"));
CHECK_FALSE(c.valid());
CHECK_FALSE(c.unterminated_quote());
@@ -944,7 +952,7 @@ TEST_CASE("converter test invalid split conversions") {
{
// unterminated escaped quote
c.convert<std::string, std::string, double, std::string>(
std::ignore = c.convert<std::string, std::string, double, std::string>(
buff(R"(just,some,2,"strings\")"));
CHECK_FALSE(c.valid());
CHECK(c.unterminated_quote());
@@ -958,27 +966,32 @@ TEST_CASE("converter test invalid split conversions with exceptions") {
c;
// mismatched quote
REQUIRE_EXCEPTION(c.convert<std::string, std::string, double, char>(
buff(R"( "just , some , "12.3","a" )")));
REQUIRE_EXCEPTION(std::ignore =
c.convert<std::string, std::string, double, char>(
buff(R"( "just , some , "12.3","a" )")));
CHECK_FALSE(c.unterminated_quote());
// unterminated quote
REQUIRE_EXCEPTION(c.convert<std::string, std::string, double, std::string>(
buff(R"( ju\,st , "so,me" , 12.34 , "str""ings)")));
REQUIRE_EXCEPTION(
std::ignore = c.convert<std::string, std::string, double, std::string>(
buff(R"( ju\,st , "so,me" , 12.34 , "str""ings)")));
CHECK(c.unterminated_quote());
// unterminated escape
REQUIRE_EXCEPTION(c.convert<std::string, std::string, double, std::string>(
buff(R"(just,some,2,strings\)")));
REQUIRE_EXCEPTION(
std::ignore = c.convert<std::string, std::string, double, std::string>(
buff(R"(just,some,2,strings\)")));
CHECK_FALSE(c.unterminated_quote());
// unterminated escape while quoting
REQUIRE_EXCEPTION(c.convert<std::string, std::string, double, std::string>(
buff(R"(just,some,2,"strings\)")));
REQUIRE_EXCEPTION(
std::ignore = c.convert<std::string, std::string, double, std::string>(
buff(R"(just,some,2,"strings\)")));
CHECK_FALSE(c.unterminated_quote());
// unterminated escaped quote
REQUIRE_EXCEPTION(c.convert<std::string, std::string, double, std::string>(
buff(R"(just,some,2,"strings\")")));
REQUIRE_EXCEPTION(
std::ignore = c.convert<std::string, std::string, double, std::string>(
buff(R"(just,some,2,"strings\")")));
CHECK(c.unterminated_quote());
}

View File

@@ -1,5 +1,4 @@
#include "test_helpers.hpp"
#include <algorithm>
#define SSP_DISABLE_FAST_FLOAT
#include <ss/extract.hpp>

View File

@@ -212,6 +212,7 @@ template <typename T>
}
};
// Evade small string optimization
out.reserve(sizeof(out) + 1);
copy_if_whitespaces();

View File

@@ -12,8 +12,9 @@
#include <unordered_set>
namespace {
[[maybe_unused]] void replace_all(std::string& s, const std::string& from,
const std::string& to) {
#ifdef _WIN32
void replace_all(std::string& s, const std::string& from,
const std::string& to) {
if (from.empty()) return;
size_t start_pos = 0;
while ((start_pos = s.find(from, start_pos)) != std::string::npos) {
@@ -21,6 +22,7 @@ namespace {
start_pos += to.length();
}
}
#endif
template <typename... Ts>
void expect_error_on_command(ss::parser<Ts...>& p,
@@ -56,7 +58,7 @@ struct X {
double d;
std::string s;
std::string to_string() const {
[[nodiscard]] std::string to_string() const {
if (s == empty) {
return "";
}
@@ -67,14 +69,15 @@ struct X {
.append(delim)
.append(s);
}
auto tied() const {
[[nodiscard]] auto tied() const {
return std::tie(i, d, s);
}
};
template <typename T>
std::enable_if_t<ss::has_m_tied_t<T>, bool> operator==(const T& lhs,
const T& rhs) {
[[nodiscard]] std::enable_if_t<ss::has_m_tied_t<T>, bool> operator==(
const T& lhs, const T& rhs) {
return lhs.tied() == rhs.tied();
}

View File

@@ -57,7 +57,7 @@ struct Y {
.append(s3);
}
auto tied() const {
[[nodiscard]] auto tied() const {
return std::tie(s1, s2, s3);
}
};
@@ -115,7 +115,8 @@ TEST_CASE_TEMPLATE("test line method", T, ParserOptionCombinations) {
CHECK_EQ(p.line(), expected_line);
while (!p.eof()) {
auto _ = p.template get_next<std::string, std::string, std::string>();
std::ignore =
p.template get_next<std::string, std::string, std::string>();
++expected_line;
CHECK_EQ(p.line(), expected_line);
}

View File

@@ -51,14 +51,16 @@ TEST_CASE_TEMPLATE("test moving of parsed composite values", T,
// to compile is enough
return;
auto [p, _] = make_parser<buffer_mode, ErrorMode>("", "");
p.template try_next<my_string, my_string, my_string>()
.template or_else<my_string, my_string, my_string, my_string>(
[](auto&&) {})
.template or_else<my_string>([](auto&) {})
.template or_else<xyz>([](auto&&) {})
.template or_object<xyz, my_string, my_string, my_string>([](auto&&) {})
.template or_else<std::tuple<my_string, my_string, my_string>>(
[](auto&, auto&, auto&) {});
std::ignore =
p.template try_next<my_string, my_string, my_string>()
.template or_else<my_string, my_string, my_string, my_string>(
[](auto&&) {})
.template or_else<my_string>([](auto&) {})
.template or_else<xyz>([](auto&&) {})
.template or_object<xyz, my_string, my_string, my_string>(
[](auto&&) {})
.template or_else<std::tuple<my_string, my_string, my_string>>(
[](auto&, auto&, auto&) {});
}
TEST_CASE_TEMPLATE("parser test string error mode", BufferMode, std::true_type,
@@ -73,7 +75,7 @@ TEST_CASE_TEMPLATE("parser test string error mode", BufferMode, std::true_type,
auto [p, _] = make_parser<BufferMode::value, ss::string_error>(f.name, ",");
REQUIRE_FALSE(p.eof());
p.template get_next<int>();
std::ignore = p.template get_next<int>();
CHECK_FALSE(p.valid());
CHECK_FALSE(p.error_msg().empty());
}
@@ -92,7 +94,7 @@ TEST_CASE_TEMPLATE("parser throw on error mode", BufferMode, std::true_type,
REQUIRE_FALSE(p.eof());
try {
p.template get_next<int>();
std::ignore = p.template get_next<int>();
FAIL("Expected exception...");
} catch (const std::exception& e) {
CHECK_FALSE(std::string{e.what()}.empty());
@@ -148,7 +150,8 @@ TEST_CASE_TEMPLATE("test quote multiline", T, ParserOptionCombinations) {
make_parser<buffer_mode, ErrorMode, ss::quote<'"'>>(f.name, ",");
while (!p.eof()) {
auto command = [&p_no_multiline = p_no_multiline] {
p_no_multiline.template get_next<int, double, std::string>();
std::ignore =
p_no_multiline.template get_next<int, double, std::string>();
};
expect_error_on_command(p_no_multiline, command);
}

View File

@@ -83,7 +83,7 @@ void test_unterminated_line(const std::vector<std::string>& lines,
size_t line = 0;
while (!p.eof()) {
auto command = [&p = p] {
p.template get_next<int, double, std::string>();
std::ignore = p.template get_next<int, double, std::string>();
};
if (line == bad_line) {

View File

@@ -228,7 +228,7 @@ void test_invalid_fields(const std::vector<std::string>& lines,
auto [p, _] = make_parser<buffer_mode, ErrorMode>(f.name, ",");
auto command = [&p = p, &fields = fields] {
p.use_fields(fields.at(0));
p.template get_next<std::string, std::string>();
std::ignore = p.template get_next<std::string, std::string>();
};
check_header(p);
@@ -428,7 +428,7 @@ TEST_CASE_TEMPLATE("test invalid header", T, ParserOptionCombinations) {
{
auto [p, _] =
make_parser<buffer_mode, ErrorMode, ss::quote<'"'>>(f.name);
auto command = [&p = p] { p.header(); };
auto command = [&p = p] { std::ignore = p.header(); };
expect_error_on_command(p, command);
CHECK_EQ(p.raw_header(), "\"Int");
}
@@ -437,7 +437,7 @@ TEST_CASE_TEMPLATE("test invalid header", T, ParserOptionCombinations) {
auto [p, _] =
make_parser<buffer_mode, ErrorMode, ss::quote<'"'>, ss::multiline>(
f.name);
auto command = [&p = p] { p.header(); };
auto command = [&p = p] { std::ignore = p.header(); };
expect_error_on_command(p, command);
CHECK_EQ(p.raw_header(), "\"Int");
}
@@ -445,7 +445,7 @@ TEST_CASE_TEMPLATE("test invalid header", T, ParserOptionCombinations) {
{
auto [p, _] = make_parser<buffer_mode, ErrorMode, ss::quote<'"'>,
ss::escape<'\\'>, ss::multiline>(f.name);
auto command = [&p = p] { p.header(); };
auto command = [&p = p] { std::ignore = p.header(); };
expect_error_on_command(p, command);
CHECK_EQ(p.raw_header(), "\"Int");
}
@@ -460,7 +460,7 @@ TEST_CASE_TEMPLATE("test invalid header", T, ParserOptionCombinations) {
{
auto [p, _] =
make_parser<buffer_mode, ErrorMode, ss::escape<'\\'>>(f.name);
auto command = [&p = p] { p.header(); };
auto command = [&p = p] { std::ignore = p.header(); };
expect_error_on_command(p, command);
CHECK_EQ(p.raw_header(), "Int\\");
}
@@ -468,7 +468,7 @@ TEST_CASE_TEMPLATE("test invalid header", T, ParserOptionCombinations) {
{
auto [p, _] = make_parser<buffer_mode, ErrorMode, ss::escape<'\\'>,
ss::multiline>(f.name);
auto command = [&p = p] { p.header(); };
auto command = [&p = p] { std::ignore = p.header(); };
expect_error_on_command(p, command);
CHECK_EQ(p.raw_header(), "Int\\");
}
@@ -476,7 +476,7 @@ TEST_CASE_TEMPLATE("test invalid header", T, ParserOptionCombinations) {
{
auto [p, _] = make_parser<buffer_mode, ErrorMode, ss::escape<'\\'>,
ss::quote<'"'>, ss::multiline>(f.name);
auto command = [&p = p] { p.header(); };
auto command = [&p = p] { std::ignore = p.header(); };
expect_error_on_command(p, command);
CHECK_EQ(p.raw_header(), "Int\\");
}

View File

@@ -85,8 +85,8 @@ struct column {
};
template <typename... Ts>
column make_column(const std::string& input_header,
const std::vector<field>& input_fields) {
[[nodiscard]] column make_column(const std::string& input_header,
const std::vector<field>& input_fields) {
using setup = ss::setup<Ts...>;
std::vector<field> filtered_fields;
@@ -127,8 +127,8 @@ column make_column(const std::string& input_header,
}
template <typename... Ts>
std::vector<std::string> generate_csv_data(const std::vector<field>& data,
const std::string& delim) {
[[nodiscard]] std::vector<std::string> generate_csv_data(
const std::vector<field>& data, const std::string& delim) {
(void)delim;
using setup = ss::setup<Ts...>;
constexpr static auto escape = '\\';

View File

@@ -9,4 +9,3 @@ TEST_CASE("parser test various cases version 2 segment 1") {
test_option_combinations3<escape>();
#endif
}

View File

@@ -10,4 +10,3 @@ TEST_CASE("parser test various cases version 2 segment 2") {
test_option_combinations3<escape, quote>();
#endif
}

View File

@@ -11,4 +11,3 @@ TEST_CASE("parser test various cases version 2 segment 3") {
test_option_combinations3<quote, multiline>();
#endif
}

View File

@@ -12,4 +12,3 @@ TEST_CASE("parser test various cases version 2 segment 4") {
test_option_combinations3<escape, quote, multiline_r>();
#endif
}

View File

@@ -13,4 +13,3 @@ TEST_CASE("parser test various cases version 2 segment 5") {
test_option_combinations<escape, quote, multiline, trimr>();
#endif
}

View File

@@ -8,4 +8,3 @@ TEST_CASE("parser test various cases version 2 segment 6") {
test_option_combinations3<escape, quote, multiline>();
}