From c47f8e04e3d9ca6d7519b21280052c08fb260b42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 16 Oct 2016 00:56:21 +0200 Subject: [PATCH] Math: test for size of long double. In order to have predictable results in the tests. --- src/Magnum/Math/Test/TypeTraitsTest.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/Magnum/Math/Test/TypeTraitsTest.cpp b/src/Magnum/Math/Test/TypeTraitsTest.cpp index 68e8a7c33..cf7aa6ebe 100644 --- a/src/Magnum/Math/Test/TypeTraitsTest.cpp +++ b/src/Magnum/Math/Test/TypeTraitsTest.cpp @@ -36,6 +36,7 @@ namespace Magnum { namespace Math { namespace Test { struct TypeTraitsTest: Corrade::TestSuite::Tester { explicit TypeTraitsTest(); + void sizeOfLongDouble(); void name(); template void equalsIntegral(); @@ -94,7 +95,8 @@ struct { } TypeTraitsTest::TypeTraitsTest() { - addTests({&TypeTraitsTest::name, + addTests({&TypeTraitsTest::sizeOfLongDouble, + &TypeTraitsTest::name, &TypeTraitsTest::equalsIntegral, &TypeTraitsTest::equalsIntegral, @@ -148,6 +150,20 @@ TypeTraitsTest::TypeTraitsTest() { }, EqualsZeroDataCount); } +void TypeTraitsTest::sizeOfLongDouble() { + #ifdef CORRADE_TARGET_EMSCRIPTEN + CORRADE_SKIP("Not defined in Emscripten."); + #else + #ifdef _MSC_VER + CORRADE_COMPARE(sizeof(long double), 8); + CORRADE_EXPECT_FAIL("long double is equivalent to double on MSVC."); + #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::name(), "UnsignedShort"); CORRADE_COMPARE(TypeTraits::name(), "Float");