diff --git a/src/Magnum/Math/Test/CMakeLists.txt b/src/Magnum/Math/Test/CMakeLists.txt index 1e6ed6867d..a3813af3d7 100644 --- a/src/Magnum/Math/Test/CMakeLists.txt +++ b/src/Magnum/Math/Test/CMakeLists.txt @@ -42,7 +42,7 @@ corrade_add_test(MathVector2Test Vector2Test.cpp LIBRARIES MagnumMathTestLib) corrade_add_test(MathVector3Test Vector3Test.cpp LIBRARIES MagnumMathTestLib) corrade_add_test(MathVector4Test Vector4Test.cpp LIBRARIES MagnumMathTestLib) -foreach(_test VectorTest Vector4Test) +foreach(_test VectorTest Vector2Test Vector3Test Vector4Test) corrade_add_test(Cpp14Math${_test} ${_test}.cpp LIBRARIES MagnumMathTestLib) set_target_properties(Cpp14Math${_test} PROPERTIES CORRADE_CXX_STANDARD 14) target_compile_definitions(Cpp14Math${_test} PRIVATE TESTING_CONSTEXPR CORRADE_GRACEFUL_ASSERT) diff --git a/src/Magnum/Math/Test/Vector2Test.cpp b/src/Magnum/Math/Test/Vector2Test.cpp index 9b225e4d84..0f43ba1b87 100644 --- a/src/Magnum/Math/Test/Vector2Test.cpp +++ b/src/Magnum/Math/Test/Vector2Test.cpp @@ -32,6 +32,8 @@ #include "Magnum/Math/StrictWeakOrdering.h" #include "Magnum/Math/Swizzle.h" +#include "Cpp14VectorTest.h" + struct Vec2 { float x, y; }; @@ -57,6 +59,7 @@ namespace Test { namespace { struct Vector2Test: Corrade::TestSuite::Tester { explicit Vector2Test(); +#ifndef SKIP_TESTING void construct(); void constructDefault(); void constructNoInit(); @@ -76,6 +79,9 @@ struct Vector2Test: Corrade::TestSuite::Tester { void swizzleType(); void debug(); +#else + void skipTesting(); +#endif }; typedef Math::Vector3 Vector3i; @@ -83,7 +89,14 @@ typedef Math::Vector2 Vector2; typedef Math::Vector2 Vector2i; Vector2Test::Vector2Test() { - addTests({&Vector2Test::construct, +#ifndef TESTING_CONSTEXPR + setTestName("MathVector2Test"); +#else + setTestName("Cpp14MathVector2Test"); +#endif + addTests({ +#ifndef SKIP_TESTING + &Vector2Test::construct, &Vector2Test::constructDefault, &Vector2Test::constructNoInit, &Vector2Test::constructOneValue, @@ -101,9 +114,15 @@ Vector2Test::Vector2Test() { &Vector2Test::strictWeakOrdering, &Vector2Test::swizzleType, - &Vector2Test::debug}); + &Vector2Test::debug +#else + &Vector2Test::skipTesting +#endif + }); } +#ifndef SKIP_TESTING + void Vector2Test::construct() { constexpr Vector2 a = {1.5f, 2.5f}; CORRADE_COMPARE(a, (Vector<2, Float>(1.5f, 2.5f))); @@ -197,7 +216,7 @@ void Vector2Test::convert() { } void Vector2Test::access() { - MAGNUM_CONSTEXPR14 Vector2 vec(1.0f, -2.0f); + CE Vector2 vec(1.0f, -2.0f); CORRADE_COMPARE(vec.x(), 1.0f); CORRADE_COMPARE(vec.y(), -2.0f); @@ -209,8 +228,8 @@ void Vector2Test::access() { } void Vector2Test::cross() { - MAGNUM_CONSTEXPR14 Vector2i a(1, -1); - MAGNUM_CONSTEXPR14 Vector2i b(4, 3); + CE Vector2i a(1, -1); + CE Vector2i b(4, 3); CORRADE_COMPARE(Math::cross(a, b), 7); CORRADE_COMPARE(Math::cross({a, 0}, {b, 0}), Vector3i(0, 0, Math::cross(a, b))); @@ -268,6 +287,11 @@ void Vector2Test::debug() { Debug(&o) << Vector2(0.5f, 15.0f); CORRADE_COMPARE(o.str(), "Vector(0.5, 15)\n"); } +#else +void Vector2Test::skipTesting() { + CORRADE_SKIP("Relaxed constexpr not supported by the compiler."); +} +#endif }}}} diff --git a/src/Magnum/Math/Test/Vector3Test.cpp b/src/Magnum/Math/Test/Vector3Test.cpp index 92ba66f926..c69f9a6470 100644 --- a/src/Magnum/Math/Test/Vector3Test.cpp +++ b/src/Magnum/Math/Test/Vector3Test.cpp @@ -23,6 +23,8 @@ DEALINGS IN THE SOFTWARE. */ +#include "Cpp14VectorTest.h" + #include #include #include @@ -57,6 +59,7 @@ namespace Test { namespace { struct Vector3Test: Corrade::TestSuite::Tester { explicit Vector3Test(); +#ifndef SKIP_TESTING void construct(); void constructDefault(); void constructNoInit(); @@ -76,6 +79,9 @@ struct Vector3Test: Corrade::TestSuite::Tester { void swizzleType(); void debug(); +#else + void skipTesting(); +#endif }; typedef Math::Vector3 Vector3; @@ -83,7 +89,14 @@ typedef Math::Vector3 Vector3i; typedef Math::Vector2 Vector2; Vector3Test::Vector3Test() { - addTests({&Vector3Test::construct, +#ifndef TESTING_CONSTEXPR + setTestName("MathVector3Test"); +#else + setTestName("Cpp14MathVector3Test"); +#endif + addTests({ +#ifndef SKIP_TESTING + &Vector3Test::construct, &Vector3Test::constructDefault, &Vector3Test::constructNoInit, &Vector3Test::constructOneValue, @@ -101,9 +114,13 @@ Vector3Test::Vector3Test() { &Vector3Test::strictWeakOrdering, &Vector3Test::swizzleType, - &Vector3Test::debug}); + &Vector3Test::debug +#else + &Vector3Test::skipTesting +#endif + }); } - +#ifndef SKIP_TESTING void Vector3Test::construct() { constexpr Vector3 a = {1.0f, 2.5f, -3.0f}; CORRADE_COMPARE(a, (Vector<3, Float>(1.0f, 2.5f, -3.0f))); @@ -206,7 +223,7 @@ void Vector3Test::convert() { } void Vector3Test::access() { - MAGNUM_CONSTEXPR14 Vector3 vec(1.0f, -2.0f, 5.0f); + CE Vector3 vec(1.0f, -2.0f, 5.0f); CORRADE_COMPARE(vec.x(), 1.0f); CORRADE_COMPARE(vec.r(), 1.0f); CORRADE_COMPARE(vec.y(), -2.0f); @@ -230,8 +247,8 @@ void Vector3Test::access() { } void Vector3Test::cross() { - MAGNUM_CONSTEXPR14 Vector3i a(1, -1, 1); - MAGNUM_CONSTEXPR14 Vector3i b(4, 3, 7); + CE Vector3i a(1, -1, 1); + CE Vector3i b(4, 3, 7); CORRADE_COMPARE(Math::cross(a, b), Vector3i(-10, -3, 7)); } @@ -255,7 +272,7 @@ void Vector3Test::scales() { } void Vector3Test::twoComponent() { - MAGNUM_CONSTEXPR14 Vector3 a(1.0f, 2.0f, 3.0f); + CE Vector3 a(1.0f, 2.0f, 3.0f); CORRADE_COMPARE(a.xy(), Vector2(1.0f, 2.0f)); constexpr Vector3 b(1.0f, 2.0f, 3.0f); @@ -292,7 +309,11 @@ void Vector3Test::debug() { Debug(&o) << Vector3(0.5f, 15.0f, 1.0f); CORRADE_COMPARE(o.str(), "Vector(0.5, 15, 1)\n"); } - +#else +void Vector3Test::skipTesting() { + CORRADE_SKIP("Relaxed constexpr not supported by the compiler."); +} +#endif }}}} CORRADE_TEST_MAIN(Magnum::Math::Test::Vector3Test)