|
|
|
|
@ -37,7 +37,6 @@ namespace Magnum { namespace Math { namespace Test { namespace {
|
|
|
|
|
struct TypeTraitsTest: Corrade::TestSuite::Tester { |
|
|
|
|
explicit TypeTraitsTest(); |
|
|
|
|
|
|
|
|
|
void sizeOfLongDouble(); |
|
|
|
|
void name(); |
|
|
|
|
|
|
|
|
|
void isScalar(); |
|
|
|
|
@ -78,27 +77,25 @@ struct {
|
|
|
|
|
Float getStep(Float) const { return aStep; } |
|
|
|
|
Double get(Double) const { return b; } |
|
|
|
|
Double getStep(Double) const { return bStep; } |
|
|
|
|
#ifndef CORRADE_TARGET_EMSCRIPTEN |
|
|
|
|
long double get(long double) const { return c; } |
|
|
|
|
long double getStep(long double) const { return cStep; } |
|
|
|
|
#endif |
|
|
|
|
} EqualsZeroData[EqualsZeroDataCount] = { |
|
|
|
|
{"", -3.141592653589793f, 5.0e-5f, -3.141592653589793, 5.0e-14, -3.141592653589793l, |
|
|
|
|
#if !defined(_MSC_VER) && (!defined(CORRADE_TARGET_ANDROID) || __LP64__) |
|
|
|
|
#ifndef CORRADE_LONG_DOUBLE_SAME_AS_DOUBLE |
|
|
|
|
5.0e-17l |
|
|
|
|
#else |
|
|
|
|
5.0e-14 |
|
|
|
|
#endif |
|
|
|
|
}, |
|
|
|
|
{"small", 1.0e-6f, 5.0e-6f, -1.0e-15, 5.0e-15, 1.0e-18l, |
|
|
|
|
#if !defined(_MSC_VER) && (!defined(CORRADE_TARGET_ANDROID) || __LP64__) |
|
|
|
|
#ifndef CORRADE_LONG_DOUBLE_SAME_AS_DOUBLE |
|
|
|
|
5.0e-18l |
|
|
|
|
#else |
|
|
|
|
5.0e-15 |
|
|
|
|
#endif |
|
|
|
|
}, |
|
|
|
|
{"large", 12345.0f, 0.2f, 12345678901234.0, 0.2, |
|
|
|
|
#if !defined(_MSC_VER) && (!defined(CORRADE_TARGET_ANDROID) || __LP64__) |
|
|
|
|
#ifndef CORRADE_LONG_DOUBLE_SAME_AS_DOUBLE |
|
|
|
|
-12345678901234567.0l, |
|
|
|
|
#else |
|
|
|
|
-12345678901234.0, |
|
|
|
|
@ -107,8 +104,7 @@ struct {
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
TypeTraitsTest::TypeTraitsTest() { |
|
|
|
|
addTests({&TypeTraitsTest::sizeOfLongDouble, |
|
|
|
|
&TypeTraitsTest::name, |
|
|
|
|
addTests({&TypeTraitsTest::name, |
|
|
|
|
|
|
|
|
|
&TypeTraitsTest::isScalar, |
|
|
|
|
&TypeTraitsTest::isVector, |
|
|
|
|
@ -128,10 +124,8 @@ TypeTraitsTest::TypeTraitsTest() {
|
|
|
|
|
&TypeTraitsTest::equalsIntegral<Short>, |
|
|
|
|
&TypeTraitsTest::equalsIntegral<UnsignedInt>, |
|
|
|
|
&TypeTraitsTest::equalsIntegral<Int>, |
|
|
|
|
#ifndef CORRADE_TARGET_EMSCRIPTEN |
|
|
|
|
&TypeTraitsTest::equalsIntegral<UnsignedLong>, |
|
|
|
|
&TypeTraitsTest::equalsIntegral<Long>, |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
&TypeTraitsTest::equalsHalf, |
|
|
|
|
|
|
|
|
|
@ -155,37 +149,19 @@ TypeTraitsTest::TypeTraitsTest() {
|
|
|
|
|
&TypeTraitsTest::equalsZeroIntegral<Short>, |
|
|
|
|
&TypeTraitsTest::equalsZeroIntegral<UnsignedInt>, |
|
|
|
|
&TypeTraitsTest::equalsZeroIntegral<Int>, |
|
|
|
|
#ifndef CORRADE_TARGET_EMSCRIPTEN |
|
|
|
|
&TypeTraitsTest::equalsZeroIntegral<UnsignedLong>, |
|
|
|
|
&TypeTraitsTest::equalsZeroIntegral<Long>, |
|
|
|
|
#endif |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
addInstancedTests<TypeTraitsTest>({ |
|
|
|
|
&TypeTraitsTest::equalsZeroFloatingPoint<Float>, |
|
|
|
|
&TypeTraitsTest::equalsZeroFloatingPoint<Double>, |
|
|
|
|
#ifndef CORRADE_TARGET_EMSCRIPTEN |
|
|
|
|
&TypeTraitsTest::equalsZeroFloatingPoint<long double> |
|
|
|
|
#endif |
|
|
|
|
}, EqualsZeroDataCount); |
|
|
|
|
&TypeTraitsTest::equalsZeroFloatingPoint<long double>}, |
|
|
|
|
EqualsZeroDataCount); |
|
|
|
|
|
|
|
|
|
addTests({&TypeTraitsTest::equal}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void TypeTraitsTest::sizeOfLongDouble() { |
|
|
|
|
#ifdef CORRADE_TARGET_EMSCRIPTEN |
|
|
|
|
CORRADE_SKIP("Not defined in Emscripten."); |
|
|
|
|
#else |
|
|
|
|
#if defined(_MSC_VER) || (defined(CORRADE_TARGET_ANDROID) && !__LP64__) |
|
|
|
|
CORRADE_COMPARE(sizeof(long double), 8); |
|
|
|
|
CORRADE_EXPECT_FAIL("long double is equivalent to double on MSVC and 32-bit Android."); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
/* It's 80 bit, but has to be aligned somehow, so 128 bits / 16 bytes */ |
|
|
|
|
CORRADE_COMPARE(sizeof(long double), 16); |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void TypeTraitsTest::name() { |
|
|
|
|
CORRADE_COMPARE(TypeTraits<UnsignedShort>::name(), std::string{"UnsignedShort"}); |
|
|
|
|
CORRADE_COMPARE(TypeTraits<Float>::name(), std::string{"Float"}); |
|
|
|
|
@ -222,9 +198,7 @@ void TypeTraitsTest::isIntegral() {
|
|
|
|
|
|
|
|
|
|
CORRADE_VERIFY(IsIntegral<Int>::value); |
|
|
|
|
CORRADE_VERIFY((IsIntegral<Vector<7, UnsignedInt>>::value)); |
|
|
|
|
#ifndef CORRADE_TARGET_EMSCRIPTEN |
|
|
|
|
CORRADE_VERIFY(IsIntegral<Vector2<Long>>::value); |
|
|
|
|
#endif |
|
|
|
|
CORRADE_VERIFY(!IsIntegral<Half>::value); |
|
|
|
|
CORRADE_VERIFY(!IsIntegral<Deg<Float>>::value); |
|
|
|
|
CORRADE_VERIFY(!IsIntegral<char*>::value); |
|
|
|
|
@ -236,9 +210,7 @@ void TypeTraitsTest::isFloatingPoint() {
|
|
|
|
|
CORRADE_VERIFY(!(IsFloatingPoint<Vector<7, UnsignedInt>>::value)); |
|
|
|
|
CORRADE_VERIFY(IsFloatingPoint<Double>::value); |
|
|
|
|
CORRADE_VERIFY((IsFloatingPoint<Vector<2, Float>>::value)); |
|
|
|
|
#ifndef CORRADE_TARGET_EMSCRIPTEN |
|
|
|
|
CORRADE_VERIFY(IsFloatingPoint<Vector2<long double>>::value); |
|
|
|
|
#endif |
|
|
|
|
CORRADE_VERIFY(IsFloatingPoint<Deg<Float>>::value); |
|
|
|
|
CORRADE_VERIFY(IsFloatingPoint<Color4<Half>>::value); |
|
|
|
|
CORRADE_VERIFY((IsFloatingPoint<Unit<Rad, Float>>::value)); |
|
|
|
|
|