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

Side by Side Diff: gpu/config/gpu_control_list_string_info_unittest.cc

Issue 452293002: Use RE string pattern matching for blacklist strings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 months 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "gpu/config/gpu_control_list.h"
6 #include "testing/gtest/include/gtest/gtest.h"
7
8 namespace gpu {
9
10 class StringInfoTest : public testing::Test {
11 public:
12 StringInfoTest() { }
13 virtual ~StringInfoTest() { }
14
15 typedef GpuControlList::StringInfo StringInfo;
16 };
17
18 TEST_F(StringInfoTest, ValidStringInfo) {
19 const std::string op[] = {
20 "contains",
21 "beginwith",
22 "endwith",
23 "="
24 };
25 for (size_t i = 0; i < arraysize(op); ++i) {
26 {
27 StringInfo info(op[i], std::string());
28 EXPECT_TRUE(info.IsValid());
29 }
30 {
31 StringInfo info(op[i], "hello");
32 EXPECT_TRUE(info.IsValid());
33 }
34 }
35 }
36
37 TEST_F(StringInfoTest, InvalidStringInfo) {
38 const std::string op[] = {
39 "Contains",
40 "BeginWith",
41 "EndWith",
42 " =",
43 "= "
44 };
45 for (size_t i = 0; i < arraysize(op); ++i) {
46 StringInfo info(op[i], "hello");
47 EXPECT_FALSE(info.IsValid());
48 }
49 }
50
51 TEST_F(StringInfoTest, StringComparison) {
52 {
53 StringInfo info("contains", "happy");
54 EXPECT_TRUE(info.Contains("unhappy"));
55 EXPECT_TRUE(info.Contains("happy1"));
56 EXPECT_TRUE(info.Contains("happy"));
57 EXPECT_TRUE(info.Contains("a happy dog"));
58 EXPECT_TRUE(info.Contains("Happy"));
59 EXPECT_TRUE(info.Contains("HAPPY"));
60 EXPECT_FALSE(info.Contains("ha-ppy"));
61 }
62 {
63 StringInfo info("beginwith", "happy");
64 EXPECT_FALSE(info.Contains("unhappy"));
65 EXPECT_TRUE(info.Contains("happy1"));
66 EXPECT_TRUE(info.Contains("happy"));
67 EXPECT_FALSE(info.Contains("a happy dog"));
68 EXPECT_TRUE(info.Contains("Happy"));
69 EXPECT_TRUE(info.Contains("HAPPY"));
70 EXPECT_FALSE(info.Contains("ha-ppy"));
71 }
72 {
73 StringInfo info("endwith", "happy");
74 EXPECT_TRUE(info.Contains("unhappy"));
75 EXPECT_FALSE(info.Contains("happy1"));
76 EXPECT_TRUE(info.Contains("happy"));
77 EXPECT_FALSE(info.Contains("a happy dog"));
78 EXPECT_TRUE(info.Contains("Happy"));
79 EXPECT_TRUE(info.Contains("HAPPY"));
80 EXPECT_FALSE(info.Contains("ha-ppy"));
81 }
82 {
83 StringInfo info("=", "happy");
84 EXPECT_FALSE(info.Contains("unhappy"));
85 EXPECT_FALSE(info.Contains("happy1"));
86 EXPECT_TRUE(info.Contains("happy"));
87 EXPECT_FALSE(info.Contains("a happy dog"));
88 EXPECT_TRUE(info.Contains("Happy"));
89 EXPECT_TRUE(info.Contains("HAPPY"));
90 EXPECT_FALSE(info.Contains("ha-ppy"));
91 EXPECT_FALSE(info.Contains("ha ppy"));
92 EXPECT_FALSE(info.Contains(" happy"));
93 EXPECT_FALSE(info.Contains("happy "));
94 }
95 }
96
97 } // namespace gpu
98
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698