| 112 | }; |
| 113 | |
| 114 | TEST(TestRegexpCompileToProg, Simple) { |
| 115 | int failed = 0; |
| 116 | for (size_t i = 0; i < arraysize(tests); i++) { |
| 117 | const re2::Test& t = tests[i]; |
| 118 | Regexp* re = Regexp::Parse(t.regexp, Regexp::PerlX|Regexp::Latin1, NULL); |
| 119 | if (re == NULL) { |
| 120 | LOG(ERROR) << "Cannot parse: " << t.regexp; |
| 121 | failed++; |
| 122 | continue; |
| 123 | } |
| 124 | Prog* prog = re->CompileToProg(0); |
| 125 | if (prog == NULL) { |
| 126 | LOG(ERROR) << "Cannot compile: " << t.regexp; |
| 127 | re->Decref(); |
| 128 | failed++; |
| 129 | continue; |
| 130 | } |
| 131 | ASSERT_TRUE(re->CompileToProg(1) == NULL); |
| 132 | std::string s = prog->Dump(); |
| 133 | if (s != t.code) { |
| 134 | LOG(ERROR) << "Incorrect compiled code for: " << t.regexp; |
| 135 | LOG(ERROR) << "Want:\n" << t.code; |
| 136 | LOG(ERROR) << "Got:\n" << s; |
| 137 | failed++; |
| 138 | } |
| 139 | delete prog; |
| 140 | re->Decref(); |
| 141 | } |
| 142 | EXPECT_EQ(failed, 0); |
| 143 | } |
| 144 | |
| 145 | static void DumpByteMap(StringPiece pattern, Regexp::ParseFlags flags, |
| 146 | std::string* bytemap) { |
nothing calls this directly
no test coverage detected