From: Mikko Rasa Date: Sun, 2 Jun 2019 13:21:40 +0000 (+0300) Subject: Improve readability of Matrix test cases with typedefs X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=8d7271ce74a1550c1987e94e1770cd9fe0aeb865;p=libs%2Fmath.git Improve readability of Matrix test cases with typedefs --- diff --git a/tests/matrix.cpp b/tests/matrix.cpp index 1b01cbc..6f57888 100644 --- a/tests/matrix.cpp +++ b/tests/matrix.cpp @@ -8,6 +8,12 @@ using namespace Msp; class MatrixTests: public Test::RegisteredTest { +private: + typedef LinAl::SquareMatrix Matrix2d; + typedef LinAl::Matrix Matrix3x2d; + typedef LinAl::Matrix Matrix2x3d; + typedef LinAl::SquareMatrix Matrix3d; + public: MatrixTests(); @@ -22,7 +28,7 @@ private: MatrixTests::MatrixTests() { add(&MatrixTests::multiply, "Multiplication"); - add(&MatrixTests::invert, "Inversion"); + add(&MatrixTests::invert, "Inversion"); } void MatrixTests::multiply() @@ -35,10 +41,10 @@ void MatrixTests::multiply() 9, 3, 9, 6 }; - LinAl::Matrix a(data); - LinAl::Matrix b(data+6); - EXPECT_EQUAL(a*b, (LinAl::Matrix(data+12))); - EXPECT_EQUAL(b*a, (LinAl::Matrix(data+21))); + Matrix3x2d a(data); + Matrix2x3d b(data+6); + EXPECT_EQUAL(a*b, Matrix3d(data+12)); + EXPECT_EQUAL(b*a, Matrix2d(data+21)); } template @@ -59,7 +65,7 @@ void MatrixTests::invert() 1, 4, 2, 4, 8, 6, 2, 2, 4 }; - LinAl::SquareMatrix m(data); - LinAl::SquareMatrix i = LinAl::invert(m); + Matrix3d m(data); + Matrix3d i = LinAl::invert(m); EXPECT(is_identity(i*m)); }