mirror of
https://github.com/yhirose/cpp-peglib.git
synced 2024-12-23 04:15:31 +00:00
Added a unit test.
This commit is contained in:
parent
46470071f3
commit
fdf10521c6
19
test/test.cc
19
test/test.cc
@ -505,6 +505,25 @@ TEST_CASE("Predicate test", "[general]")
|
|||||||
REQUIRE(ret == false);
|
REQUIRE(ret == false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("Ignore semantic value of 'and' predicate test", "[general]")
|
||||||
|
{
|
||||||
|
peg parser(
|
||||||
|
" START <- _ &HELLO HELLO_WORLD '.' "
|
||||||
|
" HELLO_WORLD <- HELLO 'World' _ "
|
||||||
|
" HELLO <- 'Hello' _ "
|
||||||
|
" ~_ <- [ \t\r\n]* "
|
||||||
|
);
|
||||||
|
|
||||||
|
parser.enable_ast(false);
|
||||||
|
|
||||||
|
shared_ptr<Ast> ast;
|
||||||
|
auto ret = parser.parse("Hello World.", ast);
|
||||||
|
|
||||||
|
REQUIRE(ret == true);
|
||||||
|
REQUIRE(ast->nodes.size() == 1);
|
||||||
|
REQUIRE(ast->nodes[0]->name == "HELLO_WORLD");
|
||||||
|
}
|
||||||
|
|
||||||
bool exact(Grammar& g, const char* d, const char* s) {
|
bool exact(Grammar& g, const char* d, const char* s) {
|
||||||
auto n = strlen(s);
|
auto n = strlen(s);
|
||||||
auto r = g[d].parse(s, n);
|
auto r = g[d].parse(s, n);
|
||||||
|
Loading…
Reference in New Issue
Block a user