diff --git a/test/test_converter.cpp b/test/test_converter.cpp index 34cc0cf..6ded5f7 100644 --- a/test/test_converter.cpp +++ b/test/test_converter.cpp @@ -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("junk"); + CHECK(!c.valid()); + CHECK(!c.error_msg().empty()); + + c.set_error_mode(ss::error_mode::Bool); + c.convert("junk"); + CHECK(!c.valid()); + CHECK(c.error_msg().empty()); +} diff --git a/test/test_parser.cpp b/test/test_parser.cpp index ecb8bf3..c1eae76 100644 --- a/test/test_parser.cpp +++ b/test/test_parser.cpp @@ -438,3 +438,26 @@ TEST_CASE("testing the moving of parsed composite values") { .or_else>( [](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(); + CHECK(!p.valid()); + CHECK(!p.error_msg().empty()); + + p.set_error_mode(ss::error_mode::Bool); + + REQUIRE(!p.eof()); + p.get_next(); + CHECK(!p.valid()); + CHECK(p.error_msg().empty()); +}