Preparing for debian package
[ACL.git] / test / string_regex.cpp
1 /*******************************************************
2  *  Unit test for the String class
3  *
4  * test regular expression operations
5  ******************************************************
6  *
7  */
8
9 #include "String.h"
10 #include <assert.h>
11
12 int main()
13 {
14    // TODO: test regex coinstructors
15
16    // A simple regular expression
17    regex nr("[0-9]+");
18
19    // Regular expression matching
20    String s1 = "abcdef";
21    String s2 = "abd123def";
22
23    std::cout << "Regular expression matching.\n";
24    assert((s1 == nr) == false);
25    assert((s2 == nr) == true);
26
27    // Select a substring with a regex
28
29    String match;
30
31    match = s2(nr);
32    std::cout << "The matching part of \"" << s2 << "\" is \"" << match << "\"\n";
33    assert(match == "123");
34
35    return 0;
36 }
37