Skip to content

Commit

Permalink
try different regex tests
Browse files Browse the repository at this point in the history
  • Loading branch information
djmott committed Jul 2, 2016
1 parent 8a98585 commit 0191bf8
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions tests/test_parse.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace test_grammar{
STRING_(Snafoo);
STRING_(ABC);
STRING_(XYZ);
REGEX(Version, "ABC\\-[[:digit:]]\\.[[:digit:]]");
REGEX(Alphabet, "ABC[1|2|3]");
}


Expand Down Expand Up @@ -48,20 +48,27 @@ TEST(test_parser, string_case){
}

TEST(test_parser, regex_no_case){
//the regex tests fail under certain gcc versions with buggy regex implementations
std::string s = "abc-2.2";
using test_parse = xtd::parser<test_grammar::Version, true>;
using test_parse = xtd::parser<test_grammar::Alphabet, true>;
std::string s = "abc1";
EXPECT_TRUE(!!test_parse::parse(s.begin(), s.end()));
s = "snafoo";
s = "abc2";
EXPECT_TRUE(!!test_parse::parse(s.begin(), s.end()));
s = "abc3";
EXPECT_TRUE(!!test_parse::parse(s.begin(), s.end()));
s = "abc4";
EXPECT_FALSE(test_parse::parse(s.begin(), s.end()));
}


TEST(test_parser, regex_case){
std::string s = "ABC-1.1";
using test_parse = xtd::parser<test_grammar::Version>;
using test_parse = xtd::parser<test_grammar::Alphabet, true>;
std::string s = "ABC1";
EXPECT_TRUE(!!test_parse::parse(s.begin(), s.end()));
s = "ABC2";
EXPECT_TRUE(!!test_parse::parse(s.begin(), s.end()));
s = "ABC3";
EXPECT_TRUE(!!test_parse::parse(s.begin(), s.end()));
s = "abc-1.1";
s = "ABC4";
EXPECT_FALSE(test_parse::parse(s.begin(), s.end()));
}

Expand Down

0 comments on commit 0191bf8

Please sign in to comment.