Browse Source

Math: test constexpr-ness of subclass types.

Fails with libc++ because std::forward() is not constexpr in C++11 (yes,
I'm adding the test solely because of that).
pull/107/head
Vladimír Vondruš 11 years ago
parent
commit
911ed52413
  1. 5
      src/Magnum/Math/Test/MatrixTest.cpp
  2. 4
      src/Magnum/Math/Test/RangeTest.cpp
  3. 5
      src/Magnum/Math/Test/RectangularMatrixTest.cpp
  4. 4
      src/Magnum/Math/Test/VectorTest.cpp

5
src/Magnum/Math/Test/MatrixTest.cpp

@ -326,8 +326,9 @@ void MatrixTest::subclassTypes() {
} }
void MatrixTest::subclass() { void MatrixTest::subclass() {
const Mat2 a(Vec2(2.0f, 3.5f), /* Constexpr constructor */
Vec2(3.0f, 1.0f)); constexpr Mat2 a(Vec2(2.0f, 3.5f),
Vec2(3.0f, 1.0f));
Mat2 b(Vec2(2.0f, 3.5f), Mat2 b(Vec2(2.0f, 3.5f),
Vec2(3.0f, 1.0f)); Vec2(3.0f, 1.0f));
CORRADE_COMPARE(a[1], Vec2(3.0f, 1.0f)); CORRADE_COMPARE(a[1], Vec2(3.0f, 1.0f));

4
src/Magnum/Math/Test/RangeTest.cpp

@ -466,6 +466,10 @@ void RangeTest::subclassTypes() {
} }
void RangeTest::subclass() { void RangeTest::subclass() {
/* Constexpr constructor */
constexpr Recti a{Vector2i{34, 23}, Vector2i{47, 30}};
CORRADE_COMPARE(a.min(), (Vector2i{34, 23}));
CORRADE_COMPARE(Recti::fromSize({3, 5}, {23, 78}), CORRADE_COMPARE(Recti::fromSize({3, 5}, {23, 78}),
Recti(Vector2i{3, 5}, Vector2i{26, 83})); Recti(Vector2i{3, 5}, Vector2i{26, 83}));

5
src/Magnum/Math/Test/RectangularMatrixTest.cpp

@ -500,8 +500,9 @@ void RectangularMatrixTest::subclass() {
CORRADE_COMPARE(Mat2x2::fromDiagonal({1.0f, -2.0f}), Mat2x2(Vector2(1.0f, 0.0f), CORRADE_COMPARE(Mat2x2::fromDiagonal({1.0f, -2.0f}), Mat2x2(Vector2(1.0f, 0.0f),
Vector2(0.0f, -2.0f))); Vector2(0.0f, -2.0f)));
const Mat2x2 a(Vector2(1.0f, -3.0f), /* Constexpr constructor */
Vector2(-3.0f, 1.0f)); constexpr Mat2x2 a(Vector2(1.0f, -3.0f),
Vector2(-3.0f, 1.0f));
CORRADE_COMPARE(-a, Mat2x2(Vector2(-1.0f, 3.0f), CORRADE_COMPARE(-a, Mat2x2(Vector2(-1.0f, 3.0f),
Vector2(3.0f, -1.0f))); Vector2(3.0f, -1.0f)));

4
src/Magnum/Math/Test/VectorTest.cpp

@ -562,6 +562,10 @@ void VectorTest::subclass() {
CORRADE_COMPARE(c, Vec2(5.0f, -1.0f)); CORRADE_COMPARE(c, Vec2(5.0f, -1.0f));
} }
/* Constexpr constructor */
constexpr const Vec2 a{-2.0f, 5.0f};
CORRADE_COMPARE(a[0], -2.0f);
CORRADE_COMPARE(Vec2(-2.0f, 5.0f) + Vec2(1.0f, -3.0f), Vec2(-1.0f, 2.0f)); CORRADE_COMPARE(Vec2(-2.0f, 5.0f) + Vec2(1.0f, -3.0f), Vec2(-1.0f, 2.0f));
CORRADE_COMPARE(Vec2(-2.0f, 5.0f) - Vec2(1.0f, -3.0f), Vec2(-3.0f, 8.0f)); CORRADE_COMPARE(Vec2(-2.0f, 5.0f) - Vec2(1.0f, -3.0f), Vec2(-3.0f, 8.0f));

Loading…
Cancel
Save