-
Notifications
You must be signed in to change notification settings - Fork 0
/
regexmatchertest.cpp
37 lines (31 loc) · 987 Bytes
/
regexmatchertest.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// regexmatchertest.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <string>
#include <iostream>
using namespace std;
bool matchString(string text);
void matchAndPrint(string text, bool expected) {
bool matchResult = matchString(text);
string success = (matchResult == expected) ? "PASS" : "FAIL";
string showOperator = expected ? "=~" : "!~";
cout << success << " : " << text << " " << showOperator << " " << "_compiled_pattern_" << endl;
}
int _tmain(int argc, _TCHAR* argv[])
{
matchAndPrint("abb", true);
matchAndPrint("babb", true);
matchAndPrint("aabb", true);
matchAndPrint("aaaabb", true);
matchAndPrint("bbbabb", true);
matchAndPrint("aababababb", true);
matchAndPrint("babaabaabb", true);
matchAndPrint("", false);
matchAndPrint("x", false);
matchAndPrint("abbc", false);
matchAndPrint("xabb", false);
matchAndPrint("ab", false);
matchAndPrint("aaaab", false);
matchAndPrint("abababaaab", false);
return 0;
}