Proper assertions for linalg test
This commit is contained in:
parent
22b2a5adde
commit
c2d4b18967
1 changed files with 13 additions and 5 deletions
|
@ -439,11 +439,11 @@ int main(void) {
|
||||||
{
|
{
|
||||||
Mat3 m = {{1, 0, 0, 0, 1, 0, 0, 0, 1}};
|
Mat3 m = {{1, 0, 0, 0, 1, 0, 0, 0, 1}};
|
||||||
float d = mat3_det(&m);
|
float d = mat3_det(&m);
|
||||||
printf("Determinant: %f\n", d);
|
assert(fabsf(d - 1.0) <= 0.01);
|
||||||
|
|
||||||
MAT3_AT(&m, 0, 0) = 2;
|
MAT3_AT(&m, 0, 0) = 2;
|
||||||
d = mat3_det(&m);
|
d = mat3_det(&m);
|
||||||
printf("Determinant: %f\n", d);
|
assert(fabsf(d - 2.0) <= 0.01);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
/* Vector tests for addition, subtraction and multiplication (scale) */
|
/* 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));
|
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 b = {5, 5, 5};
|
||||||
Vec3 c = vec3_cross(&a, &b);
|
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 a = {0, 1, 0};
|
||||||
Vec3 b = {0, 0, 1};
|
Vec3 b = {0, 0, 1};
|
||||||
Vec3 c = vec3_cross(&a, &b);
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue