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"
10 class NumberInfoTest
: public testing::Test
{
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
[] = {
30 for (size_t i
= 0; i
< arraysize(op
); ++i
) {
35 if (op
[i
] == "between")
37 FloatInfo
info(op
[i
], value1
, value2
);
38 EXPECT_TRUE(info
.IsValid());
41 const std::string value
[] = {
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
[] = {
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
[] = {
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
[] = {
128 for (size_t i
= 0; i
< arraysize(op
); ++i
) {
133 if (op
[i
] == "between")
135 IntInfo
info(op
[i
], value1
, value2
);
136 EXPECT_TRUE(info
.IsValid());
139 const std::string value
[] = {
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
[] = {
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
[] = {
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
) {
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));