From ba105b1cf66a62770a3488aeca039f9b1de4b2e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 17 Mar 2013 18:30:20 +0100 Subject: [PATCH] Math: test constexpr vector conversion. --- src/Math/Test/VectorTest.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/Math/Test/VectorTest.cpp b/src/Math/Test/VectorTest.cpp index 9b492efcd..dc6b94449 100644 --- a/src/Math/Test/VectorTest.cpp +++ b/src/Math/Test/VectorTest.cpp @@ -37,11 +37,11 @@ namespace Magnum { namespace Math { namespace Implementation { template<> struct VectorConverter<3, float, Vec3> { - inline static Vector<3, Float> from(const Vec3& other) { + inline constexpr static Vector<3, Float> from(const Vec3& other) { return {other.x, other.y, other.z}; } - inline static Vec3 to(const Vector<3, Float>& other) { + inline constexpr static Vec3 to(const Vector<3, Float>& other) { return {other[0], other[1], other[2]}; } }; @@ -198,12 +198,16 @@ void VectorTest::isNormalized() { } void VectorTest::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); + + constexpr Vec3 d(b); + CORRADE_COMPARE(d.x, a.x); + CORRADE_COMPARE(d.y, a.y); + CORRADE_COMPARE(d.z, a.z); } void VectorTest::data() {