OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "base/strings/pattern.h" | 5 #include "base/strings/pattern.h" |
6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/googletest/include/gtest/gtest.h" |
8 | 8 |
9 namespace base { | 9 namespace base { |
10 | 10 |
11 TEST(StringUtilTest, MatchPatternTest) { | 11 TEST(StringUtilTest, MatchPatternTest) { |
12 EXPECT_TRUE(MatchPattern("www.google.com", "*.com")); | 12 EXPECT_TRUE(MatchPattern("www.google.com", "*.com")); |
13 EXPECT_TRUE(MatchPattern("www.google.com", "*")); | 13 EXPECT_TRUE(MatchPattern("www.google.com", "*")); |
14 EXPECT_FALSE(MatchPattern("www.google.com", "www*.g*.org")); | 14 EXPECT_FALSE(MatchPattern("www.google.com", "www*.g*.org")); |
15 EXPECT_TRUE(MatchPattern("Hello", "H?l?o")); | 15 EXPECT_TRUE(MatchPattern("Hello", "H?l?o")); |
16 EXPECT_FALSE(MatchPattern("www.google.com", "http://*)")); | 16 EXPECT_FALSE(MatchPattern("www.google.com", "http://*)")); |
17 EXPECT_FALSE(MatchPattern("www.msn.com", "*.COM")); | 17 EXPECT_FALSE(MatchPattern("www.msn.com", "*.COM")); |
(...skipping 23 matching lines...) Expand all Loading... |
41 UTF8ToUTF16("He??o\\*1*"))); | 41 UTF8ToUTF16("He??o\\*1*"))); |
42 | 42 |
43 // This test verifies that consecutive wild cards are collapsed into 1 | 43 // This test verifies that consecutive wild cards are collapsed into 1 |
44 // wildcard (when this doesn't occur, MatchPattern reaches it's maximum | 44 // wildcard (when this doesn't occur, MatchPattern reaches it's maximum |
45 // recursion depth). | 45 // recursion depth). |
46 EXPECT_TRUE(MatchPattern(UTF8ToUTF16("Hello"), | 46 EXPECT_TRUE(MatchPattern(UTF8ToUTF16("Hello"), |
47 UTF8ToUTF16("He********************************o"))); | 47 UTF8ToUTF16("He********************************o"))); |
48 } | 48 } |
49 | 49 |
50 } // namespace base | 50 } // namespace base |
OLD | NEW |