Skip to content
Snippets Groups Projects
Commit 978e68a4 authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Add tests for ParseError

parent 0d067c5a
No related branches found
No related tags found
1 merge request!54Feature/language coverage
......@@ -69,6 +69,7 @@ add_executable (unit_tests
test_ListAffectationProcessor.cpp
test_NameProcessor.cpp
test_OStreamProcessor.cpp
test_ParseError.cpp
test_PCG.cpp
test_PugsFunctionAdapter.cpp
test_PugsAssert.cpp
......
#include <catch2/catch.hpp>
#include <language/utils/ParseError.hpp>
#include <string>
// clazy:excludeall=non-pod-global-static
TEST_CASE("ParseError", "[language]")
{
SECTION("single position")
{
const std::string source = R"(
a first line
a second line
)";
TAO_PEGTL_NAMESPACE::internal::iterator i(&source[0], 3, 1, 2);
TAO_PEGTL_NAMESPACE::position p{i, source};
ParseError parse_error("error message", p);
REQUIRE(parse_error.positions() == std::vector{p});
REQUIRE(parse_error.what() == std::string{"error message"});
}
SECTION("position list")
{
const std::string source = R"(
a first line
a second line
)";
TAO_PEGTL_NAMESPACE::internal::iterator i0(&source[0], 3, 1, 2);
TAO_PEGTL_NAMESPACE::position p0{i0, source};
TAO_PEGTL_NAMESPACE::internal::iterator i1(&source[0], 4, 1, 3);
TAO_PEGTL_NAMESPACE::position p1{i1, source};
ParseError parse_error("error message", std::vector{p0, p1});
REQUIRE(parse_error.positions() == std::vector{p0, p1});
REQUIRE(parse_error.what() == std::string{"error message"});
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment