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

Diff of /code/trunk/pcrecpp_unittest.cc

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

revision 256 by ph10, Wed Sep 19 08:57:53 2007 UTC revision 257 by ph10, Wed Sep 19 09:11:19 2007 UTC
# Line 37  Line 37 
37  #include "config.h"  #include "config.h"
38  #endif  #endif
39    
 #ifdef HAVE_WINDOWS_H  
 #define snprintf _snprintf  
 #endif  
   
40  #include <stdio.h>  #include <stdio.h>
41  #include <cassert>  #include <cassert>
42  #include <vector>  #include <vector>
# Line 114  static void LeakTest() { Line 110  static void LeakTest() {
110        initial_size = VirtualProcessSize();        initial_size = VirtualProcessSize();
111        printf("Size after 50000: %llu\n", initial_size);        printf("Size after 50000: %llu\n", initial_size);
112      }      }
113      char buf[100];      char buf[100];  // definitely big enough
114      snprintf(buf, sizeof(buf), "pat%09d", i);      sprintf(buf, "pat%09d", i);
115      RE newre(buf);      RE newre(buf);
116    }    }
117    uint64 final_size = VirtualProcessSize();    uint64 final_size = VirtualProcessSize();
# Line 923  int main(int argc, char** argv) { Line 919  int main(int argc, char** argv) {
919      long long v;      long long v;
920      static const long long max_value = 0x7fffffffffffffffLL;      static const long long max_value = 0x7fffffffffffffffLL;
921      static const long long min_value = -max_value - 1;      static const long long min_value = -max_value - 1;
922      char buf[32];      char buf[32];  // definitely big enough for a long long
923    
924      CHECK(RE("(-?\\d+)").FullMatch("100", &v)); CHECK_EQ(v, 100);      CHECK(RE("(-?\\d+)").FullMatch("100", &v)); CHECK_EQ(v, 100);
925      CHECK(RE("(-?\\d+)").FullMatch("-100",&v)); CHECK_EQ(v, -100);      CHECK(RE("(-?\\d+)").FullMatch("-100",&v)); CHECK_EQ(v, -100);
926    
927      snprintf(buf, sizeof(buf), LLD, max_value);      sprintf(buf, LLD, max_value);
928      CHECK(RE("(-?\\d+)").FullMatch(buf,&v)); CHECK_EQ(v, max_value);      CHECK(RE("(-?\\d+)").FullMatch(buf,&v)); CHECK_EQ(v, max_value);
929    
930      snprintf(buf, sizeof(buf), LLD, min_value);      sprintf(buf, LLD, min_value);
931      CHECK(RE("(-?\\d+)").FullMatch(buf,&v)); CHECK_EQ(v, min_value);      CHECK(RE("(-?\\d+)").FullMatch(buf,&v)); CHECK_EQ(v, min_value);
932    
933      snprintf(buf, sizeof(buf), LLD, max_value);      sprintf(buf, LLD, max_value);
934      assert(buf[strlen(buf)-1] != '9');      assert(buf[strlen(buf)-1] != '9');
935      buf[strlen(buf)-1]++;      buf[strlen(buf)-1]++;
936      CHECK(!RE("(-?\\d+)").FullMatch(buf, &v));      CHECK(!RE("(-?\\d+)").FullMatch(buf, &v));
937    
938      snprintf(buf, sizeof(buf), LLD, min_value);      sprintf(buf, LLD, min_value);
939      assert(buf[strlen(buf)-1] != '9');      assert(buf[strlen(buf)-1] != '9');
940      buf[strlen(buf)-1]++;      buf[strlen(buf)-1]++;
941      CHECK(!RE("(-?\\d+)").FullMatch(buf, &v));      CHECK(!RE("(-?\\d+)").FullMatch(buf, &v));
# Line 950  int main(int argc, char** argv) { Line 946  int main(int argc, char** argv) {
946      unsigned long long v;      unsigned long long v;
947      long long v2;      long long v2;
948      static const unsigned long long max_value = 0xffffffffffffffffULL;      static const unsigned long long max_value = 0xffffffffffffffffULL;
949      char buf[32];      char buf[32];  // definitely big enough for a unsigned long long
950    
951      CHECK(RE("(-?\\d+)").FullMatch("100",&v)); CHECK_EQ(v, 100);      CHECK(RE("(-?\\d+)").FullMatch("100",&v)); CHECK_EQ(v, 100);
952      CHECK(RE("(-?\\d+)").FullMatch("-100",&v2)); CHECK_EQ(v2, -100);      CHECK(RE("(-?\\d+)").FullMatch("-100",&v2)); CHECK_EQ(v2, -100);
953    
954      snprintf(buf, sizeof(buf), LLU, max_value);      sprintf(buf, LLU, max_value);
955      CHECK(RE("(-?\\d+)").FullMatch(buf,&v)); CHECK_EQ(v, max_value);      CHECK(RE("(-?\\d+)").FullMatch(buf,&v)); CHECK_EQ(v, max_value);
956    
957      assert(buf[strlen(buf)-1] != '9');      assert(buf[strlen(buf)-1] != '9');

Legend:
Removed from v.256  
changed lines
  Added in v.257

webmaster@exim.org
ViewVC Help
Powered by ViewVC 1.1.12