Browse Source

Math: test underflow/overflow when parsing vector/matrix from Configuration.

Fails as overflow is not handled.
pull/203/merge
Vladimír Vondruš 9 years ago
parent
commit
06a7677fbe
  1. 14
      src/Magnum/Math/Test/RectangularMatrixTest.cpp
  2. 8
      src/Magnum/Math/Test/VectorTest.cpp

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

@ -707,6 +707,20 @@ void RectangularMatrixTest::configuration() {
CORRADE_COMPARE(c.value("matrix"), value);
CORRADE_COMPARE(c.value<Matrix3x4>("matrix"), m);
/* Underflow */
c.setValue("underflow", "2.1 8.9 1.3 1 5 7 1.5");
CORRADE_COMPARE(c.value<Matrix3x4>("underflow"), (Matrix3x4{
Vector4{2.1f, 1.0f, 1.5f, 0.0f},
Vector4{8.9f, 5.0f, 0.0f, 0.0f},
Vector4{1.3f, 7.0f, 0.0f, 0.0f}}));
/* Overflow */
c.setValue("overflow", "2 1 8 9 1 3 1 5 7 1 6 3 3 1.5 23 17");
CORRADE_COMPARE(c.value<Matrix3x4>("overflow"), (Matrix3x4{
Vector4{2.0f, 9.0f, 1.0f, 1.0f},
Vector4{1.0f, 1.0f, 5.0f, 6.0f},
Vector4{8.0f, 3.0f, 7.0f, 3.0f}}));
}
}}}

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

@ -702,6 +702,14 @@ void VectorTest::configuration() {
c.setValue("vector", vec);
CORRADE_COMPARE(c.value("vector"), value);
CORRADE_COMPARE(c.value<Vector4>("vector"), vec);
/* Underflow */
c.setValue("underflow", "2.1 8.9");
CORRADE_COMPARE(c.value<Vector4>("underflow"), (Vector4{2.1f, 8.9f, 0.0f, 0.0f}));
/* Overflow */
c.setValue("overflow", "2 1 8 9 16 33");
CORRADE_COMPARE(c.value<Vector4>("overflow"), (Vector4{2.0f, 1.0f, 8.0f, 9.0f}));
}
}}}

Loading…
Cancel
Save