Skip to content

Commit

Permalink
Move Matrix test functions into a separate suite
Browse files Browse the repository at this point in the history
Having a single MathTest suite made sense when there were relatively few tests,
but it is unwieldy now that there are dozens.
  • Loading branch information
Matthew Mott committed Apr 4, 2021
1 parent 71c0050 commit 6e990ff
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions test/math/Matrix4.cpp
Expand Up @@ -47,7 +47,7 @@ namespace
}
}

TEST(MathTest, CreateIdentityMatrix)
TEST(MatrixTest, CreateIdentityMatrix)
{
const Matrix4 identity = Matrix4::getIdentity();
EXPECT_EQ(identity, Matrix4::byRows(1, 0, 0, 0,
Expand All @@ -56,7 +56,7 @@ TEST(MathTest, CreateIdentityMatrix)
0, 0, 0, 1));
}

TEST(MathTest, AssignMatrixComponents)
TEST(MatrixTest, AssignMatrixComponents)
{
Matrix4 identity;

Expand All @@ -83,7 +83,7 @@ TEST(MathTest, AssignMatrixComponents)
EXPECT_EQ(identity, Matrix4::getIdentity());
}

TEST(MathTest, ConstructMatrixByRows)
TEST(MatrixTest, ConstructMatrixByRows)
{
auto m = Matrix4::byRows(1, 2.5, 3, 0.34,
51, -6, 7, 9,
Expand Down Expand Up @@ -112,7 +112,7 @@ TEST(MathTest, ConstructMatrixByRows)
EXPECT_EQ(m.tw(), 32);
}

TEST(MathTest, ConstructTranslationMatrix)
TEST(MatrixTest, ConstructTranslationMatrix)
{
const Vector3 TRANS(1.5, -2939, 357);
Matrix4 tm = Matrix4::getTranslation(TRANS);
Expand All @@ -124,7 +124,7 @@ TEST(MathTest, ConstructTranslationMatrix)
EXPECT_EQ(tm.translation(), TRANS);
}

TEST(MathTest, ConstructScaleMatrix)
TEST(MatrixTest, ConstructScaleMatrix)
{
const Vector3 SCALE(0.75, 1.25, 960);
Matrix4 sm = Matrix4::getScale(SCALE);
Expand All @@ -136,7 +136,7 @@ TEST(MathTest, ConstructScaleMatrix)
EXPECT_EQ(sm.getScale(), SCALE);
}

TEST(MathTest, AccessMatrixColumnVectors)
TEST(MatrixTest, AccessMatrixColumnVectors)
{
Matrix4 m = Matrix4::byRows(1, 4, 8, -5,
2, 9, 7, 13,
Expand All @@ -161,7 +161,7 @@ TEST(MathTest, AccessMatrixColumnVectors)
1.3, 1.4, 1.5, 1.6));
}

TEST(MathTest, MatrixRawArrayData)
TEST(MatrixTest, MatrixRawArrayData)
{
Matrix4 m = Matrix4::byRows(1, 0.2, 35, 4,
5, -6, 17, 300,
Expand Down Expand Up @@ -189,7 +189,7 @@ TEST(MathTest, MatrixRawArrayData)
EXPECT_EQ(data[15], -4.5);
}

TEST(MathTest, MatrixEquality)
TEST(MatrixTest, MatrixEquality)
{
Matrix4 m1 = Matrix4::byRows(1, 2, 3.5, 4,
5, -6, 17, 800,
Expand All @@ -202,7 +202,7 @@ TEST(MathTest, MatrixEquality)
EXPECT_TRUE(m2 != Matrix4::getIdentity());
}

TEST(MathTest, MatrixTranspose)
TEST(MatrixTest, MatrixTranspose)
{
Matrix4 m = Matrix4::byRows(1, 2, 3, 4,
5, 6, 7, 8,
Expand All @@ -222,7 +222,7 @@ TEST(MathTest, MatrixTranspose)
EXPECT_EQ(m, mT);
}

TEST(MathTest, ConvertDegreesAndRadians)
TEST(MatrixTest, ConvertDegreesAndRadians)
{
math::Degrees thirtyD(30);
EXPECT_DOUBLE_EQ(thirtyD.asDegrees(), 30);
Expand All @@ -233,7 +233,7 @@ TEST(MathTest, ConvertDegreesAndRadians)
EXPECT_DOUBLE_EQ(twoPiBy3R.asRadians(), 2 * math::PI / 3.0);
}

TEST(MathTest, MatrixRotationAboutZDegrees)
TEST(MatrixTest, MatrixRotationAboutZDegrees)
{
math::Degrees angle(60.0);
double cosAngle = cos(angle.asRadians());
Expand All @@ -247,7 +247,7 @@ TEST(MathTest, MatrixRotationAboutZDegrees)
0, 0, 0, 1));
}

TEST(MathTest, MatrixRotationAboutZRadians)
TEST(MatrixTest, MatrixRotationAboutZRadians)
{
double angle = math::PI / 3.0; // 60 degrees in radians
double cosAngle = cos(angle);
Expand All @@ -261,7 +261,7 @@ TEST(MathTest, MatrixRotationAboutZRadians)
0, 0, 0, 1));
}

TEST(MathTest, MatrixRotationForAxisAngle)
TEST(MatrixTest, MatrixRotationForAxisAngle)
{
// Rotation with a zero angle should do nothing
Matrix4 noRot = Matrix4::getRotation(Vector3(0, 0, 1), 0);
Expand All @@ -280,7 +280,7 @@ TEST(MathTest, MatrixRotationForAxisAngle)
expectNear(rot45 * Vector3(1, 0, 0), Vector3(0, 1, 0));
}

TEST(MathTest, MatrixRotationForEulerXYZDegrees)
TEST(MatrixTest, MatrixRotationForEulerXYZDegrees)
{
// Test euler angle constructors
Vector3 euler(30, -55, 75);
Expand Down Expand Up @@ -324,7 +324,7 @@ TEST(MathTest, MatrixRotationForEulerXYZDegrees)
EXPECT_DOUBLE_EQ(testEuler.z(), euler.z()) << "getEulerAnglesXYZDegrees fault at z()";
}

TEST(MathTest, MatrixMultiplication)
TEST(MatrixTest, MatrixMultiplication)
{
auto a = Matrix4::byColumns(3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59);
auto b = Matrix4::byColumns(61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137);
Expand All @@ -346,7 +346,7 @@ TEST(MathTest, MatrixMultiplication)
EXPECT_EQ(b.getMultipliedBy(a), a.getPremultipliedBy(b)) << "Matrix pre-multiplication mismatch";
}

TEST(MathTest, MatrixTransformation)
TEST(MatrixTest, MatrixTransformation)
{
auto a = Matrix4::byColumns(3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59);

Expand Down Expand Up @@ -381,7 +381,7 @@ TEST(MathTest, MatrixTransformation)
EXPECT_EQ(a.tCol().z(), 53) << "Matrix4::t failed";
}

TEST(MathTest, MatrixTransformVectorEqualsMultiplication)
TEST(MatrixTest, MatrixTransformVectorEqualsMultiplication)
{
const Vector3 TRANSLATION(2, 5, -7);
auto t = Matrix4::getTranslation(TRANSLATION)
Expand Down Expand Up @@ -410,7 +410,7 @@ TEST(MathTest, MatrixTransformVectorEqualsMultiplication)
EXPECT_EQ((t * Vector4(vec3, 0)).getVector3(), t.transformDirection(vec3));
}

TEST(MathTest, MatrixScaleAffineInverse)
TEST(MatrixTest, MatrixScaleAffineInverse)
{
// Construct a scale matrix
Vector3 SCALE(2, 4, 8);
Expand All @@ -428,7 +428,7 @@ TEST(MathTest, MatrixScaleAffineInverse)
Vector3(1.0 / SCALE.x(), 1.0 / SCALE.y(), 1.0 / SCALE.z()));
}

TEST(MathTest, MatrixTranslationAffineInverse)
TEST(MatrixTest, MatrixTranslationAffineInverse)
{
// Construct a translation matrix
Vector3 TRANS(4, 32, -8);
Expand All @@ -448,7 +448,7 @@ TEST(MathTest, MatrixTranslationAffineInverse)
0, 0, 0, 1));
}

TEST(MathTest, MatrixRotationAffineInverse)
TEST(MatrixTest, MatrixRotationAffineInverse)
{
// Construct a translation matrix
const math::Degrees ANGLE(60);
Expand All @@ -463,7 +463,7 @@ TEST(MathTest, MatrixRotationAffineInverse)
expectNear(inverse, backRotMat);
}

TEST(MathTest, MatrixAffineInverseMatchesFullInverse)
TEST(MatrixTest, MatrixAffineInverseMatchesFullInverse)
{
// Create an affine transformation
Matrix4 affTrans = Matrix4::getRotationAboutZ(math::Degrees(78))
Expand Down Expand Up @@ -491,7 +491,7 @@ TEST(MathTest, MatrixAffineInverseMatchesFullInverse)
EXPECT_GT(diffInv.ty(), 8);
}

TEST(MathTest, MatrixFullInverse)
TEST(MatrixTest, MatrixFullInverse)
{
auto a = Matrix4::byColumns(3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59);

Expand All @@ -518,7 +518,7 @@ TEST(MathTest, MatrixFullInverse)
EXPECT_DOUBLE_EQ(inv.tw(), 0.3571428571428571) << "Matrix inversion failed on tw";
}

TEST(MathTest, MatrixTranslateBy)
TEST(MatrixTest, MatrixTranslateBy)
{
const Vector3 TRANS(27, -16, 0.84);

Expand Down

0 comments on commit 6e990ff

Please sign in to comment.