Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / gpu / config / gpu_control_list_number_info_unittest.cc
blobf3324d22a6523a70b71b0b46dabba500f780c2d7
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.
5 #include "gpu/config/gpu_control_list.h"
6 #include "testing/gtest/include/gtest/gtest.h"
8 namespace gpu {
10 class NumberInfoTest : public testing::Test {
11 public:
12 NumberInfoTest() { }
13 ~NumberInfoTest() override {}
15 typedef GpuControlList::FloatInfo FloatInfo;
16 typedef GpuControlList::IntInfo IntInfo;
17 typedef GpuControlList::BoolInfo BoolInfo;
20 TEST_F(NumberInfoTest, ValidFloatInfo) {
21 const std::string op[] = {
22 "=",
23 "<",
24 "<=",
25 ">",
26 ">=",
27 "any",
28 "between"
30 for (size_t i = 0; i < arraysize(op); ++i) {
31 std::string value1;
32 std::string value2;
33 if (op[i] != "any")
34 value1 = "3.14";
35 if (op[i] == "between")
36 value2 = "4.21";
37 FloatInfo info(op[i], value1, value2);
38 EXPECT_TRUE(info.IsValid());
41 const std::string value[] = {
42 "1.0E12",
43 "1.0e12",
44 "2013",
45 "1.0e-12",
46 "2.1400",
47 "-2.14",
49 for (size_t i = 0; i < arraysize(value); ++i) {
50 FloatInfo info("=", value[i], std::string());
51 EXPECT_TRUE(info.IsValid());
55 TEST_F(NumberInfoTest, InvalidFloatInfo) {
56 const std::string op[] = {
57 "=",
58 "<",
59 "<=",
60 ">",
61 ">=",
63 for (size_t i = 0; i < arraysize(op); ++i) {
64 FloatInfo info(op[i], std::string(), std::string());
65 EXPECT_FALSE(info.IsValid());
68 FloatInfo info("between", "3.14", std::string());
69 EXPECT_FALSE(info.IsValid());
71 const std::string value[] = {
72 "1.0 E12",
73 "1.0e 12",
74 " 2013",
75 "2013 ",
76 "- 2.14",
78 for (size_t i = 0; i < arraysize(value); ++i) {
79 FloatInfo info("=", value[i], std::string());
80 EXPECT_FALSE(info.IsValid());
84 TEST_F(NumberInfoTest, FloatComparison) {
86 FloatInfo info("=", "3.14", std::string());
87 EXPECT_TRUE(info.Contains(3.14f));
88 EXPECT_TRUE(info.Contains(3.1400f));
89 EXPECT_FALSE(info.Contains(3.1f));
90 EXPECT_FALSE(info.Contains(3));
93 FloatInfo info(">", "3.14", std::string());
94 EXPECT_FALSE(info.Contains(3.14f));
95 EXPECT_TRUE(info.Contains(3.141f));
96 EXPECT_FALSE(info.Contains(3.1f));
99 FloatInfo info("<=", "3.14", std::string());
100 EXPECT_TRUE(info.Contains(3.14f));
101 EXPECT_FALSE(info.Contains(3.141f));
102 EXPECT_TRUE(info.Contains(3.1f));
105 FloatInfo info("any", std::string(), std::string());
106 EXPECT_TRUE(info.Contains(3.14f));
109 FloatInfo info("between", "3.14", "5.4");
110 EXPECT_TRUE(info.Contains(3.14f));
111 EXPECT_TRUE(info.Contains(5.4f));
112 EXPECT_TRUE(info.Contains(4));
113 EXPECT_FALSE(info.Contains(5.6f));
114 EXPECT_FALSE(info.Contains(3.12f));
118 TEST_F(NumberInfoTest, ValidIntInfo) {
119 const std::string op[] = {
120 "=",
121 "<",
122 "<=",
123 ">",
124 ">=",
125 "any",
126 "between"
128 for (size_t i = 0; i < arraysize(op); ++i) {
129 std::string value1;
130 std::string value2;
131 if (op[i] != "any")
132 value1 = "3";
133 if (op[i] == "between")
134 value2 = "9";
135 IntInfo info(op[i], value1, value2);
136 EXPECT_TRUE(info.IsValid());
139 const std::string value[] = {
140 "12",
141 "-12",
143 for (size_t i = 0; i < arraysize(value); ++i) {
144 IntInfo info("=", value[i], std::string());
145 EXPECT_TRUE(info.IsValid());
149 TEST_F(NumberInfoTest, InvalidIntInfo) {
150 const std::string op[] = {
151 "=",
152 "<",
153 "<=",
154 ">",
155 ">=",
157 for (size_t i = 0; i < arraysize(op); ++i) {
158 IntInfo info(op[i], std::string(), std::string());
159 EXPECT_FALSE(info.IsValid());
162 IntInfo info("between", "3", std::string());
163 EXPECT_FALSE(info.IsValid());
165 const std::string value[] = {
166 " 12",
167 "12 ",
168 "- 12",
169 " -12",
170 "3.14"
172 for (size_t i = 0; i < arraysize(value); ++i) {
173 IntInfo info("=", value[i], std::string());
174 EXPECT_FALSE(info.IsValid());
178 TEST_F(NumberInfoTest, IntComparison) {
180 IntInfo info("=", "3", std::string());
181 EXPECT_TRUE(info.Contains(3));
182 EXPECT_FALSE(info.Contains(4));
185 IntInfo info(">", "3", std::string());
186 EXPECT_FALSE(info.Contains(2));
187 EXPECT_FALSE(info.Contains(3));
188 EXPECT_TRUE(info.Contains(4));
191 IntInfo info("<=", "3", std::string());
192 EXPECT_TRUE(info.Contains(2));
193 EXPECT_TRUE(info.Contains(3));
194 EXPECT_FALSE(info.Contains(4));
197 IntInfo info("any", std::string(), std::string());
198 EXPECT_TRUE(info.Contains(3));
201 IntInfo info("between", "3", "5");
202 EXPECT_TRUE(info.Contains(3));
203 EXPECT_TRUE(info.Contains(5));
204 EXPECT_TRUE(info.Contains(4));
205 EXPECT_FALSE(info.Contains(6));
206 EXPECT_FALSE(info.Contains(2));
210 TEST_F(NumberInfoTest, Bool) {
212 BoolInfo info(true);
213 EXPECT_TRUE(info.Contains(true));
214 EXPECT_FALSE(info.Contains(false));
217 BoolInfo info(false);
218 EXPECT_FALSE(info.Contains(true));
219 EXPECT_TRUE(info.Contains(false));
223 } // namespace gpu