/[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 96 by nigel, Fri Mar 2 13:10:43 2007 UTC revision 530 by ph10, Tue Jun 1 13:42:06 2010 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
36    #include "config.h"
37    #endif
38    
39  #include <stdio.h>  #include <stdio.h>
40  #include <string>  #include <string>
41  #include <vector>  #include <vector>
42  #include <pcre_stringpiece.h>  
43  #include <pcre_scanner.h>  #include "pcrecpp.h"
44    #include "pcre_stringpiece.h"
45    #include "pcre_scanner.h"
46    
47  #define FLAGS_unittest_stack_size   49152  #define FLAGS_unittest_stack_size   49152
48    
# Line 100  static void TestScanner() { Line 106  static void TestScanner() {
106    CHECK_EQ(comments[2].as_string(), " /* and here is gamma */\n");    CHECK_EQ(comments[2].as_string(), " /* and here is gamma */\n");
107    comments.resize(0);    comments.resize(0);
108    
109    s.GetComments(0, strchr(input, '/') - input, &comments);    s.GetComments(0, (int)(strchr(input, '/') - input), &comments);
110    CHECK_EQ(comments.size(), 0);    CHECK_EQ(comments.size(), 0);
111    comments.resize(0);    comments.resize(0);
112    
113    s.GetComments(strchr(input, '/') - input - 1, sizeof(input),    s.GetComments((int)(strchr(input, '/') - input - 1), sizeof(input),
114                  &comments);                  &comments);
115    CHECK_EQ(comments.size(), 3);    CHECK_EQ(comments.size(), 3);
116    CHECK_EQ(comments[0].as_string(), " // this sets alpha\n");    CHECK_EQ(comments[0].as_string(), " // this sets alpha\n");
# Line 112  static void TestScanner() { Line 118  static void TestScanner() {
118    CHECK_EQ(comments[2].as_string(), " /* and here is gamma */\n");    CHECK_EQ(comments[2].as_string(), " /* and here is gamma */\n");
119    comments.resize(0);    comments.resize(0);
120    
121    s.GetComments(strchr(input, '/') - input - 1,    s.GetComments((int)(strchr(input, '/') - input - 1),
122                  strchr(input + 1, '\n') - input + 1, &comments);                  (int)(strchr(input + 1, '\n') - input + 1), &comments);
123    CHECK_EQ(comments.size(), 1);    CHECK_EQ(comments.size(), 1);
124    CHECK_EQ(comments[0].as_string(), " // this sets alpha\n");    CHECK_EQ(comments[0].as_string(), " // this sets alpha\n");
125    comments.resize(0);    comments.resize(0);
# Line 122  static void TestScanner() { Line 128  static void TestScanner() {
128  static void TestBigComment() {  static void TestBigComment() {
129    string input;    string input;
130    for (int i = 0; i < 1024; ++i) {    for (int i = 0; i < 1024; ++i) {
131      char buf[1024];      char buf[1024];  // definitely big enough
132      snprintf(buf, sizeof(buf), "    # Comment %d\n", i);      sprintf(buf, "    # Comment %d\n", i);
133      input += buf;      input += buf;
134    }    }
135    input += "name = value;\n";    input += "name = value;\n";

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

webmaster@exim.org
ViewVC Help
Powered by ViewVC 1.1.12