1 /*-------------------------------------------------------------------------
2 * drawElements Internal Test Module
3 * ---------------------------------
5 * Copyright 2014 The Android Open Source Project
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
21 * \brief Seed builder tests.
22 *//*--------------------------------------------------------------------*/
24 #include "ditSeedBuilderTests.hpp"
26 #include "tcuTestLog.hpp"
27 #include "tcuVector.hpp"
28 #include "tcuSeedBuilder.hpp"
41 class SeedBuilderTest : public tcu::TestCase
44 SeedBuilderTest (tcu::TestContext& testCtx, const T& value, deUint32 seed, const char* name, const char* description)
45 : tcu::TestCase (testCtx, name, description)
51 IterateResult iterate (void)
53 TestLog& log = m_testCtx.getLog();
54 tcu::SeedBuilder builder;
58 log << TestLog::Message << "Value: " << m_value << TestLog::EndMessage;
59 log << TestLog::Message << "Expected seed: " << m_seed << TestLog::EndMessage;
60 log << TestLog::Message << "Got seed: " << builder.get() << TestLog::EndMessage;
62 if (builder.get() != m_seed)
63 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid seed");
65 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
75 class SeedBuilderMultipleValuesTest : public tcu::TestCase
78 SeedBuilderMultipleValuesTest (tcu::TestContext& testCtx)
79 : tcu::TestCase(testCtx, "multiple_values", "Test that multiple values all change the seed.")
83 IterateResult iterate (void)
85 TestLog& log = m_testCtx.getLog();
86 const deUint32 a = 77740203u;
87 const deUint32 b = 3830824200u;
89 tcu::SeedBuilder builderA;
90 tcu::SeedBuilder builderB;
91 tcu::SeedBuilder builderAB;
98 log << TestLog::Message << "Value a: " << a << ", Seed a: " << builderA.get() << TestLog::EndMessage;
99 log << TestLog::Message << "Value b: " << b << ", Seed b: " << builderB.get() << TestLog::EndMessage;
100 log << TestLog::Message << "Seed ab: " << builderAB.get() << TestLog::EndMessage;
102 if (builderA.get() == builderAB.get())
103 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Seed seems to only depends on first value.");
104 else if (builderB.get() == builderAB.get())
105 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Seed seems to only depends on second value.");
107 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
113 class SeedBuilderTests : public tcu::TestCaseGroup
116 SeedBuilderTests (tcu::TestContext& testCtx)
117 : tcu::TestCaseGroup(testCtx, "seed_builder", "Seed builder tests.")
123 addChild(new SeedBuilderTest<bool>(m_testCtx, true, 132088003u, "bool_true", "Seed from boolean true."));
124 addChild(new SeedBuilderTest<bool>(m_testCtx, false, 50600761u, "bool_false", "Seed from boolean false."));
126 addChild(new SeedBuilderTest<deInt8>(m_testCtx, 0, 62533730u, "int8_zero", "Seed from int8 zero."));
127 addChild(new SeedBuilderTest<deInt8>(m_testCtx, 1, 93914869u, "int8_one", "Seed from int8 one."));
128 addChild(new SeedBuilderTest<deInt8>(m_testCtx, -1, 115002165u, "int8_minus_one", "Seed from int8 minus one."));
130 addChild(new SeedBuilderTest<deInt16>(m_testCtx, 0, 133071403u, "int16_zero", "Seed from int16 zero."));
131 addChild(new SeedBuilderTest<deInt16>(m_testCtx, 1, 57421642u, "int16_one", "Seed from int16 one."));
132 addChild(new SeedBuilderTest<deInt16>(m_testCtx, -1, 74389771u, "int16_minus_one", "Seed from int16 minus one."));
134 addChild(new SeedBuilderTest<deInt32>(m_testCtx, 0, 75951701u, "int32_zero", "Seed from int32 zero."));
135 addChild(new SeedBuilderTest<deInt32>(m_testCtx, 1, 95780822u, "int32_one", "Seed from int32 one."));
136 addChild(new SeedBuilderTest<deInt32>(m_testCtx, -1, 73949483u, "int32_minus_one", "Seed from int32 minus one."));
138 addChild(new SeedBuilderTest<deUint8>(m_testCtx, 0, 3623298u, "uint8_zero", "Seed from uint8 zero."));
139 addChild(new SeedBuilderTest<deUint8>(m_testCtx, 1, 102006549u, "uint8_one", "Seed from uint8 one."));
140 addChild(new SeedBuilderTest<deUint8>(m_testCtx, 255, 89633493u, "uint8_max", "Seed from uint8 max."));
142 addChild(new SeedBuilderTest<deUint16>(m_testCtx, 0, 78413740u, "uint16_zero", "Seed from uint16 zero."));
143 addChild(new SeedBuilderTest<deUint16>(m_testCtx, 1, 3068621u, "uint16_one", "Seed from uint16 one."));
144 addChild(new SeedBuilderTest<deUint16>(m_testCtx, 65535, 120448140u, "uint16_max", "Seed from uint16 max."));
146 addChild(new SeedBuilderTest<deUint32>(m_testCtx, 0u, 41006057u, "uint32_zero", "Seed from uint32 zero."));
147 addChild(new SeedBuilderTest<deUint32>(m_testCtx, 1u, 54665834u, "uint32_one", "Seed from uint32 one."));
148 addChild(new SeedBuilderTest<deUint32>(m_testCtx, 4294967295u, 43990167u, "uint32_max", "Seed from uint32 max."));
150 addChild(new SeedBuilderTest<float>(m_testCtx, 0.0f, 41165361u, "float_zero", "Seed from float zero."));
151 addChild(new SeedBuilderTest<float>(m_testCtx, -0.0f, 112541574u, "float_negative_zero", "Seed from float negative zero."));
152 addChild(new SeedBuilderTest<float>(m_testCtx, 1.0f, 44355905u, "float_one", "Seed from float one."));
153 addChild(new SeedBuilderTest<float>(m_testCtx, -1.0f, 107334902u, "float_negative_one", "Seed from float negative one."));
155 addChild(new SeedBuilderTest<double>(m_testCtx, 0.0, 133470681u, "double_zero", "Seed from double zero."));
156 addChild(new SeedBuilderTest<double>(m_testCtx, -0.0, 53838958u, "double_negative_zero", "Seed from double negative zero."));
157 addChild(new SeedBuilderTest<double>(m_testCtx, 1.0, 16975104u, "double_one", "Seed from double one."));
158 addChild(new SeedBuilderTest<double>(m_testCtx, -1.0, 96606391u, "double_negative_one", "Seed from double negative one."));
160 addChild(new SeedBuilderTest<IVec2>(m_testCtx, IVec2(0), 1111532u, "ivec2_zero", "Seed from zero vector."));
161 addChild(new SeedBuilderTest<IVec3>(m_testCtx, IVec3(0), 22277704u, "ivec3_zero", "Seed from zero vector."));
162 addChild(new SeedBuilderTest<IVec4>(m_testCtx, IVec4(0), 73989201u, "ivec4_zero", "Seed from zero vector."));
164 addChild(new SeedBuilderTest<IVec2>(m_testCtx, IVec2(1), 12819708u, "ivec2_one", "Seed from one vector."));
165 addChild(new SeedBuilderTest<IVec3>(m_testCtx, IVec3(1), 134047100u, "ivec3_one", "Seed from one vector."));
166 addChild(new SeedBuilderTest<IVec4>(m_testCtx, IVec4(1), 90609878u, "ivec4_one", "Seed from one vector."));
168 addChild(new SeedBuilderTest<IVec4>(m_testCtx, IVec4(1, 2, 3, 4), 6202236u, "ivec4_1_2_3_4", "Seed from (1, 2, 3, 4) vector."));
169 addChild(new SeedBuilderTest<IVec4>(m_testCtx, IVec4(4, 3, 2, 1), 26964618u, "ivec4_4_3_2_1", "Seed from (4, 3, 2, 1) vector."));
171 addChild(new SeedBuilderMultipleValuesTest(m_testCtx));
177 tcu::TestCaseGroup* createSeedBuilderTests (tcu::TestContext& testCtx)
179 return new SeedBuilderTests(testCtx);