From 45ba444fb8943682a5e59b490a0e0e00694271fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 21 Mar 2013 17:41:44 +0100 Subject: [PATCH] Math: properly test conversion constexpr also in Vector subclasses. --- src/Math/Test/Vector2Test.cpp | 17 ++++++++++++----- src/Math/Test/Vector3Test.cpp | 19 +++++++++++++------ src/Math/Test/Vector4Test.cpp | 21 ++++++++++++++------- src/Math/Test/VectorTest.cpp | 10 ++++------ 4 files changed, 43 insertions(+), 24 deletions(-) diff --git a/src/Math/Test/Vector2Test.cpp b/src/Math/Test/Vector2Test.cpp index 1a4183445..b6a8772e4 100644 --- a/src/Math/Test/Vector2Test.cpp +++ b/src/Math/Test/Vector2Test.cpp @@ -126,11 +126,18 @@ void Vector2Test::constructCopy() { } void Vector2Test::convert() { - Vec2 a{1.5f, 2.0f}; - Vector2 b(1.5f, 2.0f); - CORRADE_COMPARE(Vector2(a), b); - CORRADE_COMPARE(Vec2(b).x, a.x); - CORRADE_COMPARE(Vec2(b).y, a.y); + constexpr Vec2 a{1.5f, 2.0f}; + constexpr Vector2 b(1.5f, 2.0f); + + constexpr Vector2 c(a); + CORRADE_COMPARE(c, b); + + #ifndef CORRADE_GCC46_COMPATIBILITY + constexpr /* Not constexpr under GCC < 4.7 */ + #endif + Vec2 d(b); + CORRADE_COMPARE(d.x, a.x); + CORRADE_COMPARE(d.y, a.y); } void Vector2Test::access() { diff --git a/src/Math/Test/Vector3Test.cpp b/src/Math/Test/Vector3Test.cpp index 05d5a697d..8e3d6b1b9 100644 --- a/src/Math/Test/Vector3Test.cpp +++ b/src/Math/Test/Vector3Test.cpp @@ -139,12 +139,19 @@ void Vector3Test::constructCopy() { } void Vector3Test::convert() { - Vec3 a{1.5f, 2.0f, -3.5f}; - Vector3 b(1.5f, 2.0f, -3.5f); - CORRADE_COMPARE(Vector3(a), b); - CORRADE_COMPARE(Vec3(b).x, a.x); - CORRADE_COMPARE(Vec3(b).y, a.y); - CORRADE_COMPARE(Vec3(b).z, a.z); + constexpr Vec3 a{1.5f, 2.0f, -3.5f}; + constexpr Vector3 b(1.5f, 2.0f, -3.5f); + + constexpr Vector3 c(a); + CORRADE_COMPARE(c, b); + + #ifndef CORRADE_GCC46_COMPATIBILITY + constexpr /* Not constexpr under GCC < 4.7 */ + #endif + Vec3 d(b); + CORRADE_COMPARE(d.x, a.x); + CORRADE_COMPARE(d.y, a.y); + CORRADE_COMPARE(d.z, a.z); } void Vector3Test::access() { diff --git a/src/Math/Test/Vector4Test.cpp b/src/Math/Test/Vector4Test.cpp index 8e09b296c..581b5c597 100644 --- a/src/Math/Test/Vector4Test.cpp +++ b/src/Math/Test/Vector4Test.cpp @@ -136,13 +136,20 @@ void Vector4Test::constructCopy() { } void Vector4Test::convert() { - Vec4 a{1.5f, 2.0f, -3.5f, -0.5f}; - Vector4 b(1.5f, 2.0f, -3.5f, -0.5f); - CORRADE_COMPARE(Vector4(a), b); - CORRADE_COMPARE(Vec4(b).x, a.x); - CORRADE_COMPARE(Vec4(b).y, a.y); - CORRADE_COMPARE(Vec4(b).z, a.z); - CORRADE_COMPARE(Vec4(b).w, a.w); + constexpr Vec4 a{1.5f, 2.0f, -3.5f, -0.5f}; + constexpr Vector4 b(1.5f, 2.0f, -3.5f, -0.5f); + + constexpr Vector4 c(a); + CORRADE_COMPARE(c, b); + + #ifndef CORRADE_GCC46_COMPATIBILITY + constexpr /* Not constexpr under GCC < 4.7 */ + #endif + Vec4 d(b); + CORRADE_COMPARE(d.x, a.x); + CORRADE_COMPARE(d.y, a.y); + CORRADE_COMPARE(d.z, a.z); + CORRADE_COMPARE(d.w, a.w); } void Vector4Test::access() { diff --git a/src/Math/Test/VectorTest.cpp b/src/Math/Test/VectorTest.cpp index b8069ffb2..dd5d1c553 100644 --- a/src/Math/Test/VectorTest.cpp +++ b/src/Math/Test/VectorTest.cpp @@ -202,17 +202,15 @@ void VectorTest::convert() { constexpr Vector3 b(1.5f, 2.0f, -3.5f); #ifndef CORRADE_GCC46_COMPATIBILITY - constexpr Vector3 c(a); - #else - Vector3 c(a); /* Not constexpr under GCC < 4.7 */ + constexpr /* Not constexpr under GCC < 4.7 */ #endif + Vector3 c(b); CORRADE_COMPARE(c, b); #ifndef CORRADE_GCC46_COMPATIBILITY - constexpr Vec3 d(b); - #else - Vec3 d(b); /* Not constexpr under GCC < 4.7 */ + constexpr /* Not constexpr under GCC < 4.7 */ #endif + Vec3 d(b); CORRADE_COMPARE(d.x, a.x); CORRADE_COMPARE(d.y, a.y); CORRADE_COMPARE(d.z, a.z);