OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
| 5 #include "extensions/common/matcher/regex_set_matcher.h" |
| 6 |
5 #include <set> | 7 #include <set> |
6 | 8 |
7 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
8 #include "extensions/common/matcher/regex_set_matcher.h" | 10 #include "url/gurl.h" |
9 #include "googleurl/src/gurl.h" | |
10 | |
11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
12 | 12 |
13 using extensions::StringPattern; | 13 using extensions::StringPattern; |
14 using extensions::RegexSetMatcher; | 14 using extensions::RegexSetMatcher; |
15 | 15 |
16 TEST(RegexSetMatcherTest, MatchRegexes) { | 16 TEST(RegexSetMatcherTest, MatchRegexes) { |
17 StringPattern pattern_1("ab.*c", 42); | 17 StringPattern pattern_1("ab.*c", 42); |
18 StringPattern pattern_2("f*f", 17); | 18 StringPattern pattern_2("f*f", 17); |
19 StringPattern pattern_3("c(ar|ra)b|brac", 239); | 19 StringPattern pattern_3("c(ar|ra)b|brac", 239); |
20 std::vector<const StringPattern*> regexes; | 20 std::vector<const StringPattern*> regexes; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 | 52 |
53 std::set<StringPattern::ID> result1; | 53 std::set<StringPattern::ID> result1; |
54 matcher.Match("http://aaa.net/", &result1); | 54 matcher.Match("http://aaa.net/", &result1); |
55 EXPECT_EQ(0U, result1.size()); | 55 EXPECT_EQ(0U, result1.size()); |
56 | 56 |
57 std::set<StringPattern::ID> result2; | 57 std::set<StringPattern::ID> result2; |
58 matcher.Match("http://aaa.net/quaaACK", &result2); | 58 matcher.Match("http://aaa.net/quaaACK", &result2); |
59 EXPECT_EQ(1U, result2.size()); | 59 EXPECT_EQ(1U, result2.size()); |
60 EXPECT_TRUE(ContainsKey(result2, 57)); | 60 EXPECT_TRUE(ContainsKey(result2, 57)); |
61 } | 61 } |
OLD | NEW |