test: add missing mat3x4 tests

Signed-off-by: Vincent Davis Jr <vince@underview.tech>
This commit is contained in:
Vincent Davis Jr
2023-08-06 13:23:31 -04:00
parent eece0b7bc9
commit f0f7b67ef4
3 changed files with 177 additions and 0 deletions

View File

@@ -37,6 +37,25 @@ test_rand_mat4x2(mat4x2 dest) {
dest[3][1] = drand48();
}
void
test_rand_mat4x3(mat4x3 dest) {
dest[0][0] = drand48();
dest[0][1] = drand48();
dest[0][2] = drand48();
dest[1][0] = drand48();
dest[1][1] = drand48();
dest[1][2] = drand48();
dest[2][0] = drand48();
dest[2][1] = drand48();
dest[2][2] = drand48();
dest[3][0] = drand48();
dest[3][1] = drand48();
dest[3][2] = drand48();
}
void
test_rand_mat3(mat3 dest) {
mat4 m4;
@@ -56,6 +75,24 @@ test_rand_mat3x2(mat3x2 dest) {
dest[2][1] = drand48();
}
void
test_rand_mat3x4(mat3x4 dest) {
dest[0][0] = drand48();
dest[0][1] = drand48();
dest[0][2] = drand48();
dest[0][3] = drand48();
dest[1][0] = drand48();
dest[1][1] = drand48();
dest[1][2] = drand48();
dest[1][3] = drand48();
dest[2][0] = drand48();
dest[2][1] = drand48();
dest[2][2] = drand48();
dest[2][3] = drand48();
}
void
test_rand_mat2(mat2 dest) {
dest[0][0] = drand48();
@@ -368,6 +405,19 @@ test_assert_mat3x4_eq_zero(mat3x4 m3x4) {
TEST_SUCCESS
}
test_status_t
test_assert_mat3x4_eq(mat3x4 m1, mat3x4 m2) {
int i, j;
for (i = 0; i < 3; i++) {
for (j = 0; j < 4; j++) {
ASSERT(fabsf(m1[i][j] - m2[i][j]) <= 0.0000009)
}
}
TEST_SUCCESS
}
test_status_t
test_assert_mat4_eq_identity(mat4 m4) {
int i, j;
@@ -437,6 +487,19 @@ test_assert_mat4x3_eq_zero(mat4x3 m4x3) {
TEST_SUCCESS
}
test_status_t
test_assert_mat4x3_eq(mat4x3 m1, mat4x3 m2) {
int i, j;
for (i = 0; i < 4; i++) {
for (j = 0; j < 3; j++) {
ASSERT(fabsf(m1[i][j] - m2[i][j]) <= 0.0000009)
}
}
TEST_SUCCESS
}
test_status_t
test_assert_eqf(float a, float b) {
ASSERT(fabsf(a - b) <= 0.000009); /* rounding errors */