/[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 199 by ph10, Tue Jul 31 14:39:09 2007 UTC revision 594 by ph10, Sun May 1 08:22:12 2011 UTC
# Line 32  Line 32 
32  // Unittest for scanner, especially GetNextComments and GetComments()  // Unittest for scanner, especially GetNextComments and GetComments()
33  // functionality.  // functionality.
34    
35  #ifdef HAVE_CONFIG_H  #ifdef HAVE_CONFIG_H
36  #include <config.h>  #include "config.h"
37  #endif  #endif
38    
39  #include <stdio.h>  #include <stdio.h>
40    #include <string.h>      /* for strchr */
41  #include <string>  #include <string>
42  #include <vector>  #include <vector>
43    
44  #include <pcrecpp.h>  #include "pcrecpp.h"
45  #include <pcre_stringpiece.h>  #include "pcre_stringpiece.h"
46  #include <pcre_scanner.h>  #include "pcre_scanner.h"
   
 #ifdef _WIN32  
 #  define snprintf _snprintf  
 #endif  
47    
48  #define FLAGS_unittest_stack_size   49152  #define FLAGS_unittest_stack_size   49152
49    
# Line 110  static void TestScanner() { Line 107  static void TestScanner() {
107    CHECK_EQ(comments[2].as_string(), " /* and here is gamma */\n");    CHECK_EQ(comments[2].as_string(), " /* and here is gamma */\n");
108    comments.resize(0);    comments.resize(0);
109    
110    s.GetComments(0, strchr(input, '/') - input, &comments);    s.GetComments(0, (int)(strchr(input, '/') - input), &comments);
111    CHECK_EQ(comments.size(), 0);    CHECK_EQ(comments.size(), 0);
112    comments.resize(0);    comments.resize(0);
113    
114    s.GetComments(strchr(input, '/') - input - 1, sizeof(input),    s.GetComments((int)(strchr(input, '/') - input - 1), sizeof(input),
115                  &comments);                  &comments);
116    CHECK_EQ(comments.size(), 3);    CHECK_EQ(comments.size(), 3);
117    CHECK_EQ(comments[0].as_string(), " // this sets alpha\n");    CHECK_EQ(comments[0].as_string(), " // this sets alpha\n");
# Line 122  static void TestScanner() { Line 119  static void TestScanner() {
119    CHECK_EQ(comments[2].as_string(), " /* and here is gamma */\n");    CHECK_EQ(comments[2].as_string(), " /* and here is gamma */\n");
120    comments.resize(0);    comments.resize(0);
121    
122    s.GetComments(strchr(input, '/') - input - 1,    s.GetComments((int)(strchr(input, '/') - input - 1),
123                  strchr(input + 1, '\n') - input + 1, &comments);                  (int)(strchr(input + 1, '\n') - input + 1), &comments);
124    CHECK_EQ(comments.size(), 1);    CHECK_EQ(comments.size(), 1);
125    CHECK_EQ(comments[0].as_string(), " // this sets alpha\n");    CHECK_EQ(comments[0].as_string(), " // this sets alpha\n");
126    comments.resize(0);    comments.resize(0);
# Line 132  static void TestScanner() { Line 129  static void TestScanner() {
129  static void TestBigComment() {  static void TestBigComment() {
130    string input;    string input;
131    for (int i = 0; i < 1024; ++i) {    for (int i = 0; i < 1024; ++i) {
132      char buf[1024];      char buf[1024];  // definitely big enough
133      snprintf(buf, sizeof(buf), "    # Comment %d\n", i);      sprintf(buf, "    # Comment %d\n", i);
134      input += buf;      input += buf;
135    }    }
136    input += "name = value;\n";    input += "name = value;\n";

Legend:
Removed from v.199  
changed lines
  Added in v.594

  ViewVC Help
Powered by ViewVC 1.1.5