From f91e141da1a4a76b0753ffbde11a3eee2e9c442a Mon Sep 17 00:00:00 2001 From: Eb3yr Date: Fri, 8 Nov 2024 18:52:38 +0000 Subject: [PATCH] Add unit test for Matrix3x2.Invert --- tests/MonoGame.Extended.Tests/Math/Matrix3x2.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/MonoGame.Extended.Tests/Math/Matrix3x2.cs b/tests/MonoGame.Extended.Tests/Math/Matrix3x2.cs index 56ab1e7b1..3a100ec6e 100644 --- a/tests/MonoGame.Extended.Tests/Math/Matrix3x2.cs +++ b/tests/MonoGame.Extended.Tests/Math/Matrix3x2.cs @@ -17,4 +17,20 @@ public void ConstructorTest() Assert.Equal(y, matrix.Y); Assert.Equal(z, matrix.Z); } + + [Fact] + public void InverseTest() + { + Matrix3x2 posDeterminant = new Matrix3x2(3, -7, 4, 2, 13, -2); + Matrix3x2 singular = new Matrix3x2(2, 1, 4, 2, 3, -4); + Matrix3x2 negDeterminant = new Matrix3x2(1, -5, 3, 2, 3, -4); + + Matrix3x2 posExpected = new Matrix3x2(1f/17, 7f/34, -2f/17, 3f/34, -1f, -5f/2); + Matrix3x2 singularExpected = Matrix3x2.Identity; + Matrix3x2 negExpected = new Matrix3x2(2f/17, 5f/17, -3f/17, 1f/17, -18f/17, -11f/17); + + Assert.Equal(Matrix3x2.Invert(posDeterminant), posExpected); + Assert.Equal(Matrix3x2.Invert(singular), singularExpected); + Assert.Equal(Matrix3x2.Invert(negDeterminant), negExpected); + } }