add tests for error mode

This commit is contained in:
ado 2020-12-27 16:51:59 +01:00
parent bb6296ef6e
commit 5a1e5b3877
2 changed files with 36 additions and 0 deletions

View File

@ -322,3 +322,16 @@ TEST_CASE("testing ss:ne restriction (not empty)") {
CHECK(tup == extracted_vector);
}
}
TEST_CASE("testing error mode") {
ss::converter c;
c.convert<int>("junk");
CHECK(!c.valid());
CHECK(!c.error_msg().empty());
c.set_error_mode(ss::error_mode::Bool);
c.convert<int>("junk");
CHECK(!c.valid());
CHECK(c.error_msg().empty());
}

View File

@ -438,3 +438,26 @@ TEST_CASE("testing the moving of parsed composite values") {
.or_else<std::tuple<my_string, my_string, my_string>>(
[](auto&, auto&, auto&) {});
}
TEST_CASE("testing error mode") {
unique_file_name f;
{
std::ofstream out{f.name};
out << "junk" << std::endl;
out << "junk" << std::endl;
}
ss::parser p(f.name, ",");
REQUIRE(!p.eof());
p.get_next<int>();
CHECK(!p.valid());
CHECK(!p.error_msg().empty());
p.set_error_mode(ss::error_mode::Bool);
REQUIRE(!p.eof());
p.get_next<int>();
CHECK(!p.valid());
CHECK(p.error_msg().empty());
}