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

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

Issue 2756793003: Move GPU blacklist and driver bug workaround list from json to data struct. (Closed)
Patch Set: pure rebase Created 3 years, 8 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
« no previous file with comments | « gpu/config/gpu_control_list_jsons.h ('k') | gpu/config/gpu_control_list_os_info_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <stddef.h>
6
7 #include "gpu/config/gpu_control_list.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9
10 namespace gpu {
11
12 class NumberInfoTest : public testing::Test {
13 public:
14 NumberInfoTest() { }
15 ~NumberInfoTest() override {}
16
17 typedef GpuControlList::FloatInfo FloatInfo;
18 typedef GpuControlList::IntInfo IntInfo;
19 typedef GpuControlList::BoolInfo BoolInfo;
20 };
21
22 TEST_F(NumberInfoTest, ValidFloatInfo) {
23 const std::string op[] = {
24 "=",
25 "<",
26 "<=",
27 ">",
28 ">=",
29 "any",
30 "between"
31 };
32 for (size_t i = 0; i < arraysize(op); ++i) {
33 std::string value1;
34 std::string value2;
35 if (op[i] != "any")
36 value1 = "3.14";
37 if (op[i] == "between")
38 value2 = "4.21";
39 FloatInfo info(op[i], value1, value2);
40 EXPECT_TRUE(info.IsValid());
41 }
42
43 const std::string value[] = {
44 "1.0E12",
45 "1.0e12",
46 "2013",
47 "1.0e-12",
48 "2.1400",
49 "-2.14",
50 };
51 for (size_t i = 0; i < arraysize(value); ++i) {
52 FloatInfo info("=", value[i], std::string());
53 EXPECT_TRUE(info.IsValid());
54 }
55 }
56
57 TEST_F(NumberInfoTest, InvalidFloatInfo) {
58 const std::string op[] = {
59 "=",
60 "<",
61 "<=",
62 ">",
63 ">=",
64 };
65 for (size_t i = 0; i < arraysize(op); ++i) {
66 FloatInfo info(op[i], std::string(), std::string());
67 EXPECT_FALSE(info.IsValid());
68 }
69 {
70 FloatInfo info("between", "3.14", std::string());
71 EXPECT_FALSE(info.IsValid());
72 }
73 const std::string value[] = {
74 "1.0 E12",
75 "1.0e 12",
76 " 2013",
77 "2013 ",
78 "- 2.14",
79 };
80 for (size_t i = 0; i < arraysize(value); ++i) {
81 FloatInfo info("=", value[i], std::string());
82 EXPECT_FALSE(info.IsValid());
83 }
84 }
85
86 TEST_F(NumberInfoTest, FloatComparison) {
87 {
88 FloatInfo info("=", "3.14", std::string());
89 EXPECT_TRUE(info.Contains(3.14f));
90 EXPECT_TRUE(info.Contains(3.1400f));
91 EXPECT_FALSE(info.Contains(3.1f));
92 EXPECT_FALSE(info.Contains(3));
93 }
94 {
95 FloatInfo info(">", "3.14", std::string());
96 EXPECT_FALSE(info.Contains(3.14f));
97 EXPECT_TRUE(info.Contains(3.141f));
98 EXPECT_FALSE(info.Contains(3.1f));
99 }
100 {
101 FloatInfo info("<=", "3.14", std::string());
102 EXPECT_TRUE(info.Contains(3.14f));
103 EXPECT_FALSE(info.Contains(3.141f));
104 EXPECT_TRUE(info.Contains(3.1f));
105 }
106 {
107 FloatInfo info("any", std::string(), std::string());
108 EXPECT_TRUE(info.Contains(3.14f));
109 }
110 {
111 FloatInfo info("between", "3.14", "5.4");
112 EXPECT_TRUE(info.Contains(3.14f));
113 EXPECT_TRUE(info.Contains(5.4f));
114 EXPECT_TRUE(info.Contains(4));
115 EXPECT_FALSE(info.Contains(5.6f));
116 EXPECT_FALSE(info.Contains(3.12f));
117 }
118 }
119
120 TEST_F(NumberInfoTest, ValidIntInfo) {
121 const std::string op[] = {
122 "=",
123 "<",
124 "<=",
125 ">",
126 ">=",
127 "any",
128 "between"
129 };
130 for (size_t i = 0; i < arraysize(op); ++i) {
131 std::string value1;
132 std::string value2;
133 if (op[i] != "any")
134 value1 = "3";
135 if (op[i] == "between")
136 value2 = "9";
137 IntInfo info(op[i], value1, value2);
138 EXPECT_TRUE(info.IsValid());
139 }
140
141 const std::string value[] = {
142 "12",
143 "-12",
144 };
145 for (size_t i = 0; i < arraysize(value); ++i) {
146 IntInfo info("=", value[i], std::string());
147 EXPECT_TRUE(info.IsValid());
148 }
149 }
150
151 TEST_F(NumberInfoTest, InvalidIntInfo) {
152 const std::string op[] = {
153 "=",
154 "<",
155 "<=",
156 ">",
157 ">=",
158 };
159 for (size_t i = 0; i < arraysize(op); ++i) {
160 IntInfo info(op[i], std::string(), std::string());
161 EXPECT_FALSE(info.IsValid());
162 }
163 {
164 IntInfo info("between", "3", std::string());
165 EXPECT_FALSE(info.IsValid());
166 }
167 const std::string value[] = {
168 " 12",
169 "12 ",
170 "- 12",
171 " -12",
172 "3.14"
173 };
174 for (size_t i = 0; i < arraysize(value); ++i) {
175 IntInfo info("=", value[i], std::string());
176 EXPECT_FALSE(info.IsValid());
177 }
178 }
179
180 TEST_F(NumberInfoTest, IntComparison) {
181 {
182 IntInfo info("=", "3", std::string());
183 EXPECT_TRUE(info.Contains(3));
184 EXPECT_FALSE(info.Contains(4));
185 }
186 {
187 IntInfo info(">", "3", std::string());
188 EXPECT_FALSE(info.Contains(2));
189 EXPECT_FALSE(info.Contains(3));
190 EXPECT_TRUE(info.Contains(4));
191 }
192 {
193 IntInfo info("<=", "3", std::string());
194 EXPECT_TRUE(info.Contains(2));
195 EXPECT_TRUE(info.Contains(3));
196 EXPECT_FALSE(info.Contains(4));
197 }
198 {
199 IntInfo info("any", std::string(), std::string());
200 EXPECT_TRUE(info.Contains(3));
201 }
202 {
203 IntInfo info("between", "3", "5");
204 EXPECT_TRUE(info.Contains(3));
205 EXPECT_TRUE(info.Contains(5));
206 EXPECT_TRUE(info.Contains(4));
207 EXPECT_FALSE(info.Contains(6));
208 EXPECT_FALSE(info.Contains(2));
209 }
210 }
211
212 TEST_F(NumberInfoTest, Bool) {
213 {
214 BoolInfo info(true);
215 EXPECT_TRUE(info.Contains(true));
216 EXPECT_FALSE(info.Contains(false));
217 }
218 {
219 BoolInfo info(false);
220 EXPECT_FALSE(info.Contains(true));
221 EXPECT_TRUE(info.Contains(false));
222 }
223 }
224
225 } // namespace gpu
226
OLDNEW
« no previous file with comments | « gpu/config/gpu_control_list_jsons.h ('k') | gpu/config/gpu_control_list_os_info_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698