Proper assertions for linalg test

This commit is contained in:
Imbus 2025-05-24 00:04:50 +02:00
parent 22b2a5adde
commit c2d4b18967

View file

@ -439,11 +439,11 @@ int main(void) {
{
Mat3 m = {{1, 0, 0, 0, 1, 0, 0, 0, 1}};
float d = mat3_det(&m);
printf("Determinant: %f\n", d);
assert(fabsf(d - 1.0) <= 0.01);
MAT3_AT(&m, 0, 0) = 2;
d = mat3_det(&m);
printf("Determinant: %f\n", d);
assert(fabsf(d - 2.0) <= 0.01);
}
{
/* Vector tests for addition, subtraction and multiplication (scale) */
@ -477,17 +477,25 @@ int main(void) {
assert(vec2_approx_eq(&m2, &v2_expected_add, 0.01));
}
{
Vec3 a = {10, 10, 10};
Vec3 a = {1, 0, 1};
Vec3 b = {5, 5, 5};
Vec3 c = vec3_cross(&a, &b);
printf("{ Vec3: %f, %f, %f }\n", c.x, c.y, c.z);
Vec3 expected = {-5, 0, 5};
assert(vec3_approx_eq(&expected, &c, 0.01));
}
{
Vec3 a = {0, 1, 0};
Vec3 b = {0, 0, 1};
Vec3 c = vec3_cross(&a, &b);
printf("{ Vec3: %f, %f, %f }\n", c.x, c.y, c.z);
Vec3 expected = {1, 0, 0};
assert(vec3_approx_eq(&expected, &c, 0.01));
}
printf("All tests passed!\n");
return 0;
}