Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(631)

Unified Diff: third_party/re2/re2/testing/regexp_test.cc

Issue 1544433002: Replace RE2 import with a dependency (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Re-Added LICENSE and OWNERS file Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/re2/re2/testing/regexp_test.cc
diff --git a/third_party/re2/re2/testing/regexp_test.cc b/third_party/re2/re2/testing/regexp_test.cc
deleted file mode 100644
index 31c76a3bf959a74d9397bc2e7edcd0a03f733c8d..0000000000000000000000000000000000000000
--- a/third_party/re2/re2/testing/regexp_test.cc
+++ /dev/null
@@ -1,82 +0,0 @@
-// Copyright 2006 The RE2 Authors. All Rights Reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// Test parse.cc, dump.cc, and tostring.cc.
-
-#include <string>
-#include <vector>
-#include "util/test.h"
-#include "re2/regexp.h"
-
-namespace re2 {
-
-// Test that overflowed ref counts work.
-TEST(Regexp, BigRef) {
- Regexp* re;
- re = Regexp::Parse("x", Regexp::NoParseFlags, NULL);
- for (int i = 0; i < 100000; i++)
- re->Incref();
- for (int i = 0; i < 100000; i++)
- re->Decref();
- CHECK_EQ(re->Ref(), 1);
- re->Decref();
-}
-
-// Test that very large Concats work.
-// Depends on overflowed ref counts working.
-TEST(Regexp, BigConcat) {
- Regexp* x;
- x = Regexp::Parse("x", Regexp::NoParseFlags, NULL);
- 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 + static_cast<int>(v.size())) << x->Ref();
- Regexp* re = Regexp::Concat(v.data(), static_cast<int>(v.size()),
- Regexp::NoParseFlags);
- CHECK_EQ(re->ToString(), string(v.size(), 'x'));
- re->Decref();
- CHECK_EQ(x->Ref(), 1) << x->Ref();
- x->Decref();
-}
-
-TEST(Regexp, NamedCaptures) {
- Regexp* x;
- RegexpStatus status;
- x = Regexp::Parse(
- "(?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();
- 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;
- want["g1"] = 1;
- want["g2"] = 3;
- EXPECT_EQ(want, *have);
- x->Decref();
- delete have;
-}
-
-TEST(Regexp, CaptureNames) {
- Regexp* x;
- RegexpStatus status;
- x = Regexp::Parse(
- "(?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();
- EXPECT_TRUE(have != NULL);
- EXPECT_EQ(3, have->size());
- map<int, string> want;
- want[1] = "g1";
- want[3] = "g2";
- want[4] = "g1";
-
- EXPECT_EQ(want, *have);
- x->Decref();
- delete have;
-}
-
-} // namespace re2
« no previous file with comments | « third_party/re2/re2/testing/regexp_generator.cc ('k') | third_party/re2/re2/testing/required_prefix_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698