Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(41)

Delta Between Two Patch Sets: re2/testing/re2_test.cc

Issue 6442107: code review 6442107: re2: eliminate global c++ constructors (Closed)
Left Patch Set: Created 12 years, 8 months ago
Right Patch Set: diff -r 61789b886064 https://code.google.com/p/re2 Created 12 years, 8 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « re2/regexp.cc ('k') | util/mutex.h » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 // -*- coding: utf-8 -*- 1 // -*- coding: utf-8 -*-
2 // Copyright 2002-2009 The RE2 Authors. All Rights Reserved. 2 // Copyright 2002-2009 The RE2 Authors. All Rights Reserved.
3 // Use of this source code is governed by a BSD-style 3 // Use of this source code is governed by a BSD-style
4 // license that can be found in the LICENSE file. 4 // license that can be found in the LICENSE file.
5 5
6 // TODO: Test extractions for PartialMatch/Consume 6 // TODO: Test extractions for PartialMatch/Consume
7 7
8 #include <sys/types.h> 8 #include <sys/types.h>
9 #include <sys/mman.h> 9 #include <sys/mman.h>
10 #include <sys/stat.h> 10 #include <sys/stat.h>
(...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after
741 } 741 }
742 { 742 {
743 int64 v; 743 int64 v;
744 static const int64 max = 0x7fffffffffffffffull; 744 static const int64 max = 0x7fffffffffffffffull;
745 static const int64 min = -max - 1; 745 static const int64 min = -max - 1;
746 char buf[32]; 746 char buf[32];
747 747
748 CHECK(RE2::FullMatch("100", "(-?\\d+)", &v)); CHECK_EQ(v, 100); 748 CHECK(RE2::FullMatch("100", "(-?\\d+)", &v)); CHECK_EQ(v, 100);
749 CHECK(RE2::FullMatch("-100", "(-?\\d+)", &v)); CHECK_EQ(v, -100); 749 CHECK(RE2::FullMatch("-100", "(-?\\d+)", &v)); CHECK_EQ(v, -100);
750 750
751 snprintf(buf, sizeof(buf), "%lld", max); 751 snprintf(buf, sizeof(buf), "%lld", (long long int)max);
752 CHECK(RE2::FullMatch(buf, "(-?\\d+)", &v)); CHECK_EQ(v, max); 752 CHECK(RE2::FullMatch(buf, "(-?\\d+)", &v)); CHECK_EQ(v, max);
753 753
754 snprintf(buf, sizeof(buf), "%lld", min); 754 snprintf(buf, sizeof(buf), "%lld", (long long int)min);
755 CHECK(RE2::FullMatch(buf, "(-?\\d+)", &v)); CHECK_EQ(v, min); 755 CHECK(RE2::FullMatch(buf, "(-?\\d+)", &v)); CHECK_EQ(v, min);
756 756
757 snprintf(buf, sizeof(buf), "%lld", max); 757 snprintf(buf, sizeof(buf), "%lld", (long long int)max);
758 assert(buf[strlen(buf)-1] != '9'); 758 assert(buf[strlen(buf)-1] != '9');
759 buf[strlen(buf)-1]++; 759 buf[strlen(buf)-1]++;
760 CHECK(!RE2::FullMatch(buf, "(-?\\d+)", &v)); 760 CHECK(!RE2::FullMatch(buf, "(-?\\d+)", &v));
761 761
762 snprintf(buf, sizeof(buf), "%lld", min); 762 snprintf(buf, sizeof(buf), "%lld", (long long int)min);
763 assert(buf[strlen(buf)-1] != '9'); 763 assert(buf[strlen(buf)-1] != '9');
764 buf[strlen(buf)-1]++; 764 buf[strlen(buf)-1]++;
765 CHECK(!RE2::FullMatch(buf, "(-?\\d+)", &v)); 765 CHECK(!RE2::FullMatch(buf, "(-?\\d+)", &v));
766 } 766 }
767 { 767 {
768 uint64 v; 768 uint64 v;
769 int64 v2; 769 int64 v2;
770 static const uint64 max = 0xffffffffffffffffull; 770 static const uint64 max = 0xffffffffffffffffull;
771 char buf[32]; 771 char buf[32];
772 772
773 CHECK(RE2::FullMatch("100", "(-?\\d+)", &v)); CHECK_EQ(v, 100); 773 CHECK(RE2::FullMatch("100", "(-?\\d+)", &v)); CHECK_EQ(v, 100);
774 CHECK(RE2::FullMatch("-100", "(-?\\d+)", &v2)); CHECK_EQ(v2, -100); 774 CHECK(RE2::FullMatch("-100", "(-?\\d+)", &v2)); CHECK_EQ(v2, -100);
775 775
776 snprintf(buf, sizeof(buf), "%llu", max); 776 snprintf(buf, sizeof(buf), "%llu", (long long unsigned)max);
777 CHECK(RE2::FullMatch(buf, "(-?\\d+)", &v)); CHECK_EQ(v, max); 777 CHECK(RE2::FullMatch(buf, "(-?\\d+)", &v)); CHECK_EQ(v, max);
778 778
779 assert(buf[strlen(buf)-1] != '9'); 779 assert(buf[strlen(buf)-1] != '9');
780 buf[strlen(buf)-1]++; 780 buf[strlen(buf)-1]++;
781 CHECK(!RE2::FullMatch(buf, "(-?\\d+)", &v)); 781 CHECK(!RE2::FullMatch(buf, "(-?\\d+)", &v));
782 } 782 }
783 } 783 }
784 784
785 TEST(RE2, FloatingPointFullMatchTypes) { 785 TEST(RE2, FloatingPointFullMatchTypes) {
786 string zeros(100, '0'); 786 string zeros(100, '0');
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after
1362 } 1362 }
1363 1363
1364 TEST(RE2, RegexpToStringLossOfAnchor) { 1364 TEST(RE2, RegexpToStringLossOfAnchor) {
1365 EXPECT_EQ(RE2("^[a-c]at", RE2::POSIX).Regexp()->ToString(), "^[a-c]at"); 1365 EXPECT_EQ(RE2("^[a-c]at", RE2::POSIX).Regexp()->ToString(), "^[a-c]at");
1366 EXPECT_EQ(RE2("^[a-c]at").Regexp()->ToString(), "(?-m:^)[a-c]at"); 1366 EXPECT_EQ(RE2("^[a-c]at").Regexp()->ToString(), "(?-m:^)[a-c]at");
1367 EXPECT_EQ(RE2("ca[t-z]$", RE2::POSIX).Regexp()->ToString(), "ca[t-z]$"); 1367 EXPECT_EQ(RE2("ca[t-z]$", RE2::POSIX).Regexp()->ToString(), "ca[t-z]$");
1368 EXPECT_EQ(RE2("ca[t-z]$").Regexp()->ToString(), "ca[t-z](?-m:$)"); 1368 EXPECT_EQ(RE2("ca[t-z]$").Regexp()->ToString(), "ca[t-z](?-m:$)");
1369 } 1369 }
1370 1370
1371 } // namespace re2 1371 } // namespace re2
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b