/[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 144 by ph10, Mon Apr 2 13:32:07 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    #ifdef _WIN32
42    #  define snprintf _snprintf
43    #endif
44    
45    #define FLAGS_unittest_stack_size   49152
46    
47  // Dies with a fatal error if the two values are not equal.  // Dies with a fatal error if the two values are not equal.
48  #define CHECK_EQ(a, b)  do {                                    \  #define CHECK_EQ(a, b)  do {                                    \
49    if ( (a) != (b) ) {                                           \    if ( (a) != (b) ) {                                           \
# Line 116  static void TestScanner() { Line 123  static void TestScanner() {
123    comments.resize(0);    comments.resize(0);
124  }  }
125    
126    static void TestBigComment() {
127      string input;
128      for (int i = 0; i < 1024; ++i) {
129        char buf[1024];
130        snprintf(buf, sizeof(buf), "    # Comment %d\n", i);
131        input += buf;
132      }
133      input += "name = value;\n";
134    
135      Scanner s(input.c_str());
136      s.SetSkipExpression("\\s+|#.*\n");
137    
138      string name;
139      string value;
140      s.Consume("(\\w+) = (\\w+);", &name, &value);
141      CHECK_EQ(name, "name");
142      CHECK_EQ(value, "value");
143    }
144    
145    // TODO: also test scanner and big-comment in a thread with a
146    //       small stack size
147    
148  int main(int argc, char** argv) {  int main(int argc, char** argv) {
149    TestScanner();    TestScanner();
150      TestBigComment();
151    
152    // Done    // Done
153    printf("OK\n");    printf("OK\n");

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

  ViewVC Help
Powered by ViewVC 1.1.5