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/substring_set_matcher.h" | 5 #include "extensions/common/matcher/substring_set_matcher.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 | 110 |
111 // Test non-match | 111 // Test non-match |
112 // String abcde | 112 // String abcde |
113 // Pattern 1 fg | 113 // Pattern 1 fg |
114 TestOnePattern("abcde", "fg", false); | 114 TestOnePattern("abcde", "fg", false); |
115 | 115 |
116 // Test empty pattern and too long pattern | 116 // Test empty pattern and too long pattern |
117 // String abcde | 117 // String abcde |
118 // Pattern 1 | 118 // Pattern 1 |
119 // Pattern 2 abcdef | 119 // Pattern 2 abcdef |
120 TestTwoPatterns("abcde", "", "abcdef", true, false); | 120 TestTwoPatterns("abcde", std::string(), "abcdef", true, false); |
121 } | 121 } |
122 | 122 |
123 TEST(SubstringSetMatcherTest, RegisterAndRemove) { | 123 TEST(SubstringSetMatcherTest, RegisterAndRemove) { |
124 SubstringSetMatcher matcher; | 124 SubstringSetMatcher matcher; |
125 | 125 |
126 StringPattern pattern_1("a", 1); | 126 StringPattern pattern_1("a", 1); |
127 StringPattern pattern_2("b", 2); | 127 StringPattern pattern_2("b", 2); |
128 StringPattern pattern_3("c", 3); | 128 StringPattern pattern_3("c", 3); |
129 | 129 |
130 std::vector<const StringPattern*> patterns; | 130 std::vector<const StringPattern*> patterns; |
(...skipping 27 matching lines...) Expand all Loading... |
158 matcher.UnregisterPatterns(patterns); | 158 matcher.UnregisterPatterns(patterns); |
159 EXPECT_TRUE(matcher.IsEmpty()); | 159 EXPECT_TRUE(matcher.IsEmpty()); |
160 } | 160 } |
161 | 161 |
162 TEST(SubstringSetMatcherTest, TestEmptyMatcher) { | 162 TEST(SubstringSetMatcherTest, TestEmptyMatcher) { |
163 SubstringSetMatcher matcher; | 163 SubstringSetMatcher matcher; |
164 std::set<int> matches; | 164 std::set<int> matches; |
165 matcher.Match("abd", &matches); | 165 matcher.Match("abd", &matches); |
166 EXPECT_TRUE(matches.empty()); | 166 EXPECT_TRUE(matches.empty()); |
167 } | 167 } |
OLD | NEW |