From 4c8415c054ffd5c7e970c24ec35c52e5ec3fba6c Mon Sep 17 00:00:00 2001 From: yhirose Date: Thu, 2 Aug 2018 21:46:17 -0400 Subject: [PATCH] Added another test case for %whitespace --- test/test.cc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/test.cc b/test/test.cc index 684d029..e1153b7 100644 --- a/test/test.cc +++ b/test/test.cc @@ -255,6 +255,23 @@ TEST_CASE("WHITESPACE test2", "[general]") REQUIRE(items[2] == "three"); } +TEST_CASE("WHITESPACE test3", "[general]") { + peg::parser parser(R"( + StrQuot <- < '"' < (StrEscape / StrChars)* > '"' > + StrEscape <- '\\' any + StrChars <- (!'"' !'\\' any)+ + any <- . + %whitespace <- [ \t]* + )"); + + parser["StrQuot"] = [](const SemanticValues& sv) { + REQUIRE(sv.token() == R"( aaa \" bbb )"); + }; + + auto ret = parser.parse(R"( " aaa \" bbb " )"); + REQUIRE(ret == true); +} + TEST_CASE("Word expression test", "[general]") { peg::parser parser(R"( ROOT <- 'hello' ','? 'world'