// // Copyright 2015 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // // mathutil_unittest: // Unit tests for the utils defined in mathutil.h // #include "mathutil.h" #include <gtest/gtest.h> usingnamespacegl; namespace { // Test the correctness of packSnorm2x16 and unpackSnorm2x16 functions. // For floats f1 and f2, unpackSnorm2x16(packSnorm2x16(f1, f2)) should be same as f1 and f2. TEST(MathUtilTest, packAndUnpackSnorm2x16) { … } // Test the correctness of packSnorm2x16 and unpackSnorm2x16 functions with infinity values, // result should be clamped to [-1, 1]. TEST(MathUtilTest, packAndUnpackSnorm2x16Infinity) { … } // Test the correctness of packUnorm2x16 and unpackUnorm2x16 functions. // For floats f1 and f2, unpackUnorm2x16(packUnorm2x16(f1, f2)) should be same as f1 and f2. TEST(MathUtilTest, packAndUnpackUnorm2x16) { … } // Test the correctness of packUnorm2x16 and unpackUnorm2x16 functions with infinity values, // result should be clamped to [0, 1]. TEST(MathUtilTest, packAndUnpackUnorm2x16Infinity) { … } // Test the correctness of packHalf2x16 and unpackHalf2x16 functions. // For floats f1 and f2, unpackHalf2x16(packHalf2x16(f1, f2)) should be same as f1 and f2. TEST(MathUtilTest, packAndUnpackHalf2x16) { … } // Test the correctness of packUnorm4x8 and unpackUnorm4x8 functions. // For floats f1 to f4, unpackUnorm4x8(packUnorm4x8(f1, f2, f3, f4)) should be same as f1 to f4. TEST(MathUtilTest, packAndUnpackUnorm4x8) { … } // Test the correctness of packSnorm4x8 and unpackSnorm4x8 functions. // For floats f1 to f4, unpackSnorm4x8(packSnorm4x8(f1, f2, f3, f4)) should be same as f1 to f4. TEST(MathUtilTest, packAndUnpackSnorm4x8) { … } // Test the correctness of gl::isNaN function. TEST(MathUtilTest, isNaN) { … } // Test the correctness of gl::isInf function. TEST(MathUtilTest, isInf) { … } TEST(MathUtilTest, CountLeadingZeros) { … } // Some basic tests. Pow2 roundUp test and test that rounding up zero produces zero. TEST(MathUtilTest, Pow2RoundUp) { … } // Non-pow2 test. TEST(MathUtilTest, BasicRoundUp) { … } // Test that rounding up zero produces zero for checked ints. TEST(MathUtilTest, CheckedRoundUpZero) { … } // Test out-of-bounds with CheckedRoundUp TEST(MathUtilTest, CheckedRoundUpInvalid) { … } // Test BitfieldReverse which reverses the order of the bits in an integer. TEST(MathUtilTest, BitfieldReverse) { … } // Test BitCount, which counts 1 bits in an integer. TEST(MathUtilTest, BitCount) { … } // Test ScanForward, which scans for the least significant 1 bit from a non-zero integer. TEST(MathUtilTest, ScanForward) { … } // Test ScanReverse, which scans for the most significant 1 bit from a non-zero integer. TEST(MathUtilTest, ScanReverse) { … } // Test FindLSB, which finds the least significant 1 bit. TEST(MathUtilTest, FindLSB) { … } // Test FindMSB, which finds the most significant 1 bit. TEST(MathUtilTest, FindMSB) { … } // Test Ldexp, which combines mantissa and exponent into a floating-point number. TEST(MathUtilTest, Ldexp) { … } // Test that Range::extend works as expected. TEST(MathUtilTest, RangeExtend) { … } // Test that Range::merge works as expected. TEST(MathUtilTest, RangMerge) { … } // Test that Range iteration works as expected. TEST(MathUtilTest, RangeIteration) { … } // Tests for clampForBitCount TEST(MathUtilTest, ClampForBitCount) { … } // Tests for float32 to float16 conversion TEST(MathUtilTest, Float32ToFloat16) { … } // Tests the RGB float to 999E5 conversion TEST(MathUtilTest, convertRGBFloatsTo999E5) { … } // Tests the 999E5 to RGB float conversion TEST(MathUtilTest, convert999E5toRGBFloats) { … } // Test sRGB conversions TEST(MathUtilTest, sRGB) { … } // Test roundToNearest with boundary values TEST(MathUtilTest, RoundToNearest) { … } // Test floatToNormalized conversions with uint8_t TEST(MathUtilTest, FloatToNormalizedUnorm8) { … } // Test floatToNormalized conversions with int8_t TEST(MathUtilTest, FloatToNormalizedSnorm8) { … } // Test floatToNormalized conversions with uint16_t TEST(MathUtilTest, FloatToNormalizedUnorm16) { … } // Test floatToNormalized conversions with int16_t TEST(MathUtilTest, FloatToNormalizedSnorm16) { … } // Test floatToNormalized conversions with uint32_t TEST(MathUtilTest, FloatToNormalizedUnorm32) { … } // Test floatToNormalized conversions with int32_t TEST(MathUtilTest, FloatToNormalizedSnorm32) { … } // Test floatToNormalized conversions with 2-bit unsigned TEST(MathUtilTest, FloatToNormalizedUnorm2) { … } // Test floatToNormalized conversions with 2-bit signed TEST(MathUtilTest, FloatToNormalizedSnorm2) { … } // Test floatToNormalized conversions with 10-bit unsigned TEST(MathUtilTest, FloatToNormalizedUnorm10) { … } // Test floatToNormalized conversions with 10-bit signed TEST(MathUtilTest, FloatToNormalizedSnorm10) { … } // Test floatToNormalized conversions with 30-bit unsigned TEST(MathUtilTest, FloatToNormalizedUnorm30) { … } // Test floatToNormalized conversions with 30-bit signed TEST(MathUtilTest, FloatToNormalizedSnorm30) { … } } // anonymous namespace