aboutsummaryrefslogtreecommitdiff
path: root/re2/testing/regexp_test.cc
diff options
context:
space:
mode:
Diffstat (limited to 're2/testing/regexp_test.cc')
-rw-r--r--re2/testing/regexp_test.cc27
1 files changed, 16 insertions, 11 deletions
diff --git a/re2/testing/regexp_test.cc b/re2/testing/regexp_test.cc
index f317cbc..7830322 100644
--- a/re2/testing/regexp_test.cc
+++ b/re2/testing/regexp_test.cc
@@ -4,9 +4,13 @@
// Test parse.cc, dump.cc, and tostring.cc.
+#include <stddef.h>
+#include <map>
#include <string>
#include <vector>
+
#include "util/test.h"
+#include "util/logging.h"
#include "re2/regexp.h"
namespace re2 {
@@ -19,7 +23,7 @@ TEST(Regexp, BigRef) {
re->Incref();
for (int i = 0; i < 100000; i++)
re->Decref();
- CHECK_EQ(re->Ref(), 1);
+ ASSERT_EQ(re->Ref(), 1);
re->Decref();
}
@@ -28,14 +32,15 @@ TEST(Regexp, BigRef) {
TEST(Regexp, BigConcat) {
Regexp* x;
x = Regexp::Parse("x", Regexp::NoParseFlags, NULL);
- vector<Regexp*> v(90000, x); // ToString bails out at 100000
- for (int i = 0; i < v.size(); i++)
+ std::vector<Regexp*> v(90000, x); // ToString bails out at 100000
+ for (size_t i = 0; i < v.size(); i++)
x->Incref();
- CHECK_EQ(x->Ref(), 1 + v.size()) << x->Ref();
- Regexp* re = Regexp::Concat(&v[0], v.size(), Regexp::NoParseFlags);
- CHECK_EQ(re->ToString(), string(v.size(), 'x'));
+ ASSERT_EQ(x->Ref(), 1 + static_cast<int>(v.size())) << x->Ref();
+ Regexp* re = Regexp::Concat(v.data(), static_cast<int>(v.size()),
+ Regexp::NoParseFlags);
+ ASSERT_EQ(re->ToString(), string(v.size(), 'x'));
re->Decref();
- CHECK_EQ(x->Ref(), 1) << x->Ref();
+ ASSERT_EQ(x->Ref(), 1) << x->Ref();
x->Decref();
}
@@ -46,11 +51,11 @@ TEST(Regexp, NamedCaptures) {
"(?P<g1>a+)|(e)(?P<g2>w*)+(?P<g1>b+)", Regexp::PerlX, &status);
EXPECT_TRUE(status.ok());
EXPECT_EQ(4, x->NumCaptures());
- const map<string, int>* have = x->NamedCaptures();
+ const std::map<string, int>* have = x->NamedCaptures();
EXPECT_TRUE(have != NULL);
EXPECT_EQ(2, have->size()); // there are only two named groups in
// the regexp: 'g1' and 'g2'.
- map<string, int> want;
+ std::map<string, int> want;
want["g1"] = 1;
want["g2"] = 3;
EXPECT_EQ(want, *have);
@@ -65,10 +70,10 @@ TEST(Regexp, CaptureNames) {
"(?P<g1>a+)|(e)(?P<g2>w*)+(?P<g1>b+)", Regexp::PerlX, &status);
EXPECT_TRUE(status.ok());
EXPECT_EQ(4, x->NumCaptures());
- const map<int, string>* have = x->CaptureNames();
+ const std::map<int, string>* have = x->CaptureNames();
EXPECT_TRUE(have != NULL);
EXPECT_EQ(3, have->size());
- map<int, string> want;
+ std::map<int, string> want;
want[1] = "g1";
want[3] = "g2";
want[4] = "g1";