Browse Source

Math: test constexpr vector conversion.

pull/278/head
Vladimír Vondruš 13 years ago
parent
commit
ba105b1cf6
  1. 20
      src/Math/Test/VectorTest.cpp

20
src/Math/Test/VectorTest.cpp

@ -37,11 +37,11 @@ namespace Magnum { namespace Math {
namespace Implementation { namespace Implementation {
template<> struct VectorConverter<3, float, Vec3> { 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}; 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]}; return {other[0], other[1], other[2]};
} }
}; };
@ -198,12 +198,16 @@ void VectorTest::isNormalized() {
} }
void VectorTest::convert() { void VectorTest::convert() {
Vec3 a{1.5f, 2.0f, -3.5f}; constexpr Vec3 a{1.5f, 2.0f, -3.5f};
Vector3 b(1.5f, 2.0f, -3.5f); constexpr Vector3 b(1.5f, 2.0f, -3.5f);
CORRADE_COMPARE(Vector3(a), b);
CORRADE_COMPARE(Vec3(b).x, a.x); constexpr Vector3 c(a);
CORRADE_COMPARE(Vec3(b).y, a.y); CORRADE_COMPARE(c, b);
CORRADE_COMPARE(Vec3(b).z, a.z);
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() { void VectorTest::data() {

Loading…
Cancel
Save