/[pcre]/code/trunk/pcre_scanner_unittest.cc
ViewVC logotype

Diff of /code/trunk/pcre_scanner_unittest.cc

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 87 by nigel, Sat Feb 24 21:41:21 2007 UTC revision 96 by nigel, Fri Mar 2 13:10:43 2007 UTC
# Line 33  Line 33 
33  // functionality.  // functionality.
34    
35  #include <stdio.h>  #include <stdio.h>
36    #include <string>
37  #include <vector>  #include <vector>
38  #include <pcre_stringpiece.h>  #include <pcre_stringpiece.h>
39  #include <pcre_scanner.h>  #include <pcre_scanner.h>
40    
41    #define FLAGS_unittest_stack_size   49152
42    
43  // Dies with a fatal error if the two values are not equal.  // Dies with a fatal error if the two values are not equal.
44  #define CHECK_EQ(a, b)  do {                                    \  #define CHECK_EQ(a, b)  do {                                    \
45    if ( (a) != (b) ) {                                           \    if ( (a) != (b) ) {                                           \
# Line 116  static void TestScanner() { Line 119  static void TestScanner() {
119    comments.resize(0);    comments.resize(0);
120  }  }
121    
122    static void TestBigComment() {
123      string input;
124      for (int i = 0; i < 1024; ++i) {
125        char buf[1024];
126        snprintf(buf, sizeof(buf), "    # Comment %d\n", i);
127        input += buf;
128      }
129      input += "name = value;\n";
130    
131      Scanner s(input.c_str());
132      s.SetSkipExpression("\\s+|#.*\n");
133    
134      string name;
135      string value;
136      s.Consume("(\\w+) = (\\w+);", &name, &value);
137      CHECK_EQ(name, "name");
138      CHECK_EQ(value, "value");
139    }
140    
141    // TODO: also test scanner and big-comment in a thread with a
142    //       small stack size
143    
144  int main(int argc, char** argv) {  int main(int argc, char** argv) {
145    TestScanner();    TestScanner();
146      TestBigComment();
147    
148    // Done    // Done
149    printf("OK\n");    printf("OK\n");

Legend:
Removed from v.87  
changed lines
  Added in v.96

webmaster@exim.org
ViewVC Help
Powered by ViewVC 1.1.12