Browse Source

Math: properly test conversion constexpr also in Vector subclasses.

pull/278/head
Vladimír Vondruš 13 years ago
parent
commit
45ba444fb8
  1. 17
      src/Math/Test/Vector2Test.cpp
  2. 19
      src/Math/Test/Vector3Test.cpp
  3. 21
      src/Math/Test/Vector4Test.cpp
  4. 10
      src/Math/Test/VectorTest.cpp

17
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() {

19
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() {

21
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() {

10
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);

Loading…
Cancel
Save