Add passing RegEx tests.
This commit is contained in:
1 parent
9336193aaf
commit
0c50ad4197
1 file changed
+14
@@ -292,9 +292,23 @@ std::string RegEx::toString() {
|
||||
void RegEx::test() {
|
||||
{
|
||||
RegEx re("a*");
|
||||
assert(re.longMatch("a") == 1);
|
||||
assert(re.longMatch("aa") == 2);
|
||||
assert(re.longMatch("aaaab") == 4);
|
||||
assert(re.longMatch("b") == 0);
|
||||
}
|
||||
|
||||
{
|
||||
RegEx re("a+");
|
||||
assert(re.longMatch("aa") == 2);
|
||||
assert(re.longMatch("aaaab") == 4);
|
||||
assert(re.longMatch("b") == -1);
|
||||
}
|
||||
|
||||
{
|
||||
RegEx re("a(bc)?");
|
||||
assert(re.longMatch("ab") == 1);
|
||||
}
|
||||
|
||||
std::cout << "RegEx tests pass\n";
|
||||
}
|
||||
Reference in new issue
Block a user