Skip to content

tests: add unit tests for matrix class increasing math utilities coverage #454

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from

Conversation

AmanMenda
Copy link
Contributor

@AmanMenda AmanMenda commented Jun 1, 2025

  • construction tests (default construction, construction with params, vector construction, copy construction)
  • indexing operator
  • arithmetic operations (addition, substraction, div, multiplication, scalar multiplication and division)
  • identity matrices
  • edges cases (zero division, large values, small values, chained operations with matrices
  • inverse tests

@JeanPhilippeKernel JeanPhilippeKernel added enhancement New feature or request area-window Work on Window system labels Jun 2, 2025
@JeanPhilippeKernel JeanPhilippeKernel moved this to In Progress in ZEngine Board Jun 2, 2025
@JeanPhilippeKernel JeanPhilippeKernel added this to the Born baby (0.2.0) milestone Jun 2, 2025
@JeanPhilippeKernel JeanPhilippeKernel requested a review from jnyfah June 2, 2025 22:37

// ========== INVERSE TESTS ==========

TEST(MatrixTest, Inverse3x3)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have inverse for 4x4 too

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, i'm working on it ;)

EXPECT_NEAR(result(0, 1), 1.0f, EPSILON); // (0*0) + 1 - 0 = 1
EXPECT_NEAR(result(1, 1), 2.0f, EPSILON); // (1*2) + 1 - 1 = 2
}

TEST(MatrixTest, ConstructionAndIndexingFloat)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be removed since there is not a comprehensive ParameterConstruction test

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I remove the entire chainedOperations test ?

Copy link
Collaborator

@jnyfah jnyfah Jun 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ohh @AmanMenda i meant just remove the ConstructionAndIndexingFloat test

Comment on lines +186 to +210
TEST(MatrixTest, MatrixMultiplication)
{
Mat3f m1(1, 2, 3, 0, 1, 4, 5, 6, 0);
Mat3f m2 = Identity<Mat3f>();

Mat3f result = m1 * m2;

// Multiplying by identity should result in the original matrix
for (size_t i = 0; i < 3; ++i)
{
for (size_t j = 0; j < 3; ++j)
{
EXPECT_NEAR(result(i, j), m1(i, j), EPSILON);
}
}

// Test specific multiplication
Mat3f a = Identity<Mat3f>();
Mat3f b(2, 0, 0, 0, 2, 0, 0, 0, 2);
Mat3f product = a * b;

EXPECT_NEAR(product(0, 0), 2.0f, EPSILON);
EXPECT_NEAR(product(1, 1), 2.0f, EPSILON);
EXPECT_NEAR(product(2, 2), 2.0f, EPSILON);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a Matrix-Vector Multiplication Testing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-window Work on Window system enhancement New feature or request
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

Add Unit Tests for Matrix and Extend Test Coverage for Math Utilities
3 participants