Browse Source

debug: various improvements to the test programs.

legacy
Sam Hocevar sam 13 years ago
parent
commit
5454005d81
3 changed files with 62 additions and 62 deletions
  1. +1
    -1
      src/debug/quad.cpp
  2. +47
    -47
      test/matrix.cpp
  3. +14
    -14
      test/trig.cpp

+ 1
- 1
src/debug/quad.cpp View File

@@ -197,7 +197,7 @@ void DebugQuad::TickDraw(float deltams)
}

/* Prepare our quad coordinates */
ivec2 const layout(5, 4);
ivec2 const layout(7, 5);
data->step = vec2(2.0f, -2.0f) / (4 * layout + ivec2(1));
data->orig = vec2(-1.0f, 1.0f) + data->step;
data->aa = data->orig;


+ 47
- 47
test/matrix.cpp View File

@@ -139,26 +139,26 @@ public:

vec3 b(a1);
vec2 a2(b);
CPPUNIT_ASSERT(b.x == a1.x);
CPPUNIT_ASSERT(b.y == a1.y);
CPPUNIT_ASSERT(b.z == 0.0f);
CPPUNIT_ASSERT_EQUAL(b.x, a1.x);
CPPUNIT_ASSERT_EQUAL(b.y, a1.y);
CPPUNIT_ASSERT_EQUAL(b.z, 0.0f);
CPPUNIT_ASSERT(a2 == a1);

vec4 c(a1);
vec2 a3(c);
CPPUNIT_ASSERT(c.x == a1.x);
CPPUNIT_ASSERT(c.y == a1.y);
CPPUNIT_ASSERT(c.z == 0.0f);
CPPUNIT_ASSERT(c.w == 0.0f);
CPPUNIT_ASSERT_EQUAL(c.x, a1.x);
CPPUNIT_ASSERT_EQUAL(c.y, a1.y);
CPPUNIT_ASSERT_EQUAL(c.z, 0.0f);
CPPUNIT_ASSERT_EQUAL(c.w, 0.0f);
CPPUNIT_ASSERT(a3 == a1);
}

void test_mat_det()
{
float d1 = triangular.det();
CPPUNIT_ASSERT(d1 == 24.0f);
CPPUNIT_ASSERT_EQUAL(d1, 24.0f);
float d2 = invertible.det();
CPPUNIT_ASSERT(d2 == -1.0f);
CPPUNIT_ASSERT_EQUAL(d2, -1.0f);
}

void test_mat_mul()
@@ -167,25 +167,25 @@ public:
mat4 m1 = identity;
mat4 m2 = m0 * m1;

CPPUNIT_ASSERT(m2[0][0] == 1.0f);
CPPUNIT_ASSERT(m2[1][0] == 0.0f);
CPPUNIT_ASSERT(m2[2][0] == 0.0f);
CPPUNIT_ASSERT(m2[3][0] == 0.0f);
CPPUNIT_ASSERT(m2[0][1] == 0.0f);
CPPUNIT_ASSERT(m2[1][1] == 1.0f);
CPPUNIT_ASSERT(m2[2][1] == 0.0f);
CPPUNIT_ASSERT(m2[3][1] == 0.0f);
CPPUNIT_ASSERT(m2[0][2] == 0.0f);
CPPUNIT_ASSERT(m2[1][2] == 0.0f);
CPPUNIT_ASSERT(m2[2][2] == 1.0f);
CPPUNIT_ASSERT(m2[3][2] == 0.0f);
CPPUNIT_ASSERT(m2[0][3] == 0.0f);
CPPUNIT_ASSERT(m2[1][3] == 0.0f);
CPPUNIT_ASSERT(m2[2][3] == 0.0f);
CPPUNIT_ASSERT(m2[3][3] == 1.0f);
CPPUNIT_ASSERT_EQUAL(m2[0][0], 1.0f);
CPPUNIT_ASSERT_EQUAL(m2[1][0], 0.0f);
CPPUNIT_ASSERT_EQUAL(m2[2][0], 0.0f);
CPPUNIT_ASSERT_EQUAL(m2[3][0], 0.0f);
CPPUNIT_ASSERT_EQUAL(m2[0][1], 0.0f);
CPPUNIT_ASSERT_EQUAL(m2[1][1], 1.0f);
CPPUNIT_ASSERT_EQUAL(m2[2][1], 0.0f);
CPPUNIT_ASSERT_EQUAL(m2[3][1], 0.0f);
CPPUNIT_ASSERT_EQUAL(m2[0][2], 0.0f);
CPPUNIT_ASSERT_EQUAL(m2[1][2], 0.0f);
CPPUNIT_ASSERT_EQUAL(m2[2][2], 1.0f);
CPPUNIT_ASSERT_EQUAL(m2[3][2], 0.0f);
CPPUNIT_ASSERT_EQUAL(m2[0][3], 0.0f);
CPPUNIT_ASSERT_EQUAL(m2[1][3], 0.0f);
CPPUNIT_ASSERT_EQUAL(m2[2][3], 0.0f);
CPPUNIT_ASSERT_EQUAL(m2[3][3], 1.0f);
}

void test_mat_inv()
@@ -195,25 +195,25 @@ public:

mat4 m2 = m0 * m1;

CPPUNIT_ASSERT(m2[0][0] == 1.0f);
CPPUNIT_ASSERT(m2[1][0] == 0.0f);
CPPUNIT_ASSERT(m2[2][0] == 0.0f);
CPPUNIT_ASSERT(m2[3][0] == 0.0f);
CPPUNIT_ASSERT(m2[0][1] == 0.0f);
CPPUNIT_ASSERT(m2[1][1] == 1.0f);
CPPUNIT_ASSERT(m2[2][1] == 0.0f);
CPPUNIT_ASSERT(m2[3][1] == 0.0f);
CPPUNIT_ASSERT(m2[0][2] == 0.0f);
CPPUNIT_ASSERT(m2[1][2] == 0.0f);
CPPUNIT_ASSERT(m2[2][2] == 1.0f);
CPPUNIT_ASSERT(m2[3][2] == 0.0f);
CPPUNIT_ASSERT(m2[0][3] == 0.0f);
CPPUNIT_ASSERT(m2[1][3] == 0.0f);
CPPUNIT_ASSERT(m2[2][3] == 0.0f);
CPPUNIT_ASSERT(m2[3][3] == 1.0f);
CPPUNIT_ASSERT_EQUAL(m2[0][0], 1.0f);
CPPUNIT_ASSERT_EQUAL(m2[1][0], 0.0f);
CPPUNIT_ASSERT_EQUAL(m2[2][0], 0.0f);
CPPUNIT_ASSERT_EQUAL(m2[3][0], 0.0f);
CPPUNIT_ASSERT_EQUAL(m2[0][1], 0.0f);
CPPUNIT_ASSERT_EQUAL(m2[1][1], 1.0f);
CPPUNIT_ASSERT_EQUAL(m2[2][1], 0.0f);
CPPUNIT_ASSERT_EQUAL(m2[3][1], 0.0f);
CPPUNIT_ASSERT_EQUAL(m2[0][2], 0.0f);
CPPUNIT_ASSERT_EQUAL(m2[1][2], 0.0f);
CPPUNIT_ASSERT_EQUAL(m2[2][2], 1.0f);
CPPUNIT_ASSERT_EQUAL(m2[3][2], 0.0f);
CPPUNIT_ASSERT_EQUAL(m2[0][3], 0.0f);
CPPUNIT_ASSERT_EQUAL(m2[1][3], 0.0f);
CPPUNIT_ASSERT_EQUAL(m2[2][3], 0.0f);
CPPUNIT_ASSERT_EQUAL(m2[3][3], 1.0f);
}

private:


+ 14
- 14
test/trig.cpp View File

@@ -44,7 +44,7 @@ public:
double f = (double)i * (1.0 / 1000.0);
double a = __builtin_sin(f);
double b = lol_sin(f);
CPPUNIT_ASSERT(fabs(a - b) <= fabs(f) * 1e-11);
CPPUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(f) * 1e-11);
}

for (int i = -10000; i < 10000; i++)
@@ -52,7 +52,7 @@ public:
double f = (double)i * (1.0 / 100000.0);
double a = __builtin_sin(f);
double b = lol_sin(f);
CPPUNIT_ASSERT(fabs(a - b) <= fabs(f) * 1e-11);
CPPUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(f) * 1e-11);
}

for (int i = -10000; i < 10000; i++)
@@ -60,7 +60,7 @@ public:
double f = (double)i * (1.0 / 1000.0);
double a = __builtin_cos(f);
double b = lol_cos(f);
CPPUNIT_ASSERT(fabs(a - b) <= fabs(f) * 1e-11);
CPPUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(f) * 1e-11);
}

for (int i = -10000; i < 10000; i++)
@@ -68,7 +68,7 @@ public:
double f = (double)i * (1.0 / 100000.0);
double a = __builtin_cos(f);
double b = lol_cos(f);
CPPUNIT_ASSERT(fabs(a - b) <= fabs(f) * 1e-11);
CPPUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(f) * 1e-11);
}

for (int i = -10000; i < 10000; i++)
@@ -78,8 +78,8 @@ public:
double a2 = __builtin_cos(f);
double b1, b2;
lol_sincos(f, &b1, &b2);
CPPUNIT_ASSERT(fabs(a1 - b1) <= fabs(f) * 1e-11);
CPPUNIT_ASSERT(fabs(a2 - b2) <= fabs(f) * 1e-11);
CPPUNIT_ASSERT_DOUBLES_EQUAL(a1, b1, fabs(f) * 1e-11);
CPPUNIT_ASSERT_DOUBLES_EQUAL(a2, b2, fabs(f) * 1e-11);
}

for (int i = -10000; i < 10000; i++)
@@ -89,8 +89,8 @@ public:
double a2 = __builtin_cos(f);
double b1, b2;
lol_sincos(f, &b1, &b2);
CPPUNIT_ASSERT(fabs(a1 - b1) <= fabs(f) * 1e-11);
CPPUNIT_ASSERT(fabs(a2 - b2) <= fabs(f) * 1e-11);
CPPUNIT_ASSERT_DOUBLES_EQUAL(a1, b1, fabs(f) * 1e-11);
CPPUNIT_ASSERT_DOUBLES_EQUAL(a2, b2, fabs(f) * 1e-11);
}

for (int i = -100000; i < 100000; i++)
@@ -99,11 +99,11 @@ public:
double a = __builtin_tan(f);
double b = lol_tan(f);
if (fabs(a) > 1e4)
CPPUNIT_ASSERT(fabs(a - b) <= fabs(a) * fabs(a) * 1e-11);
CPPUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(a) * fabs(a) * 1e-11);
else if (fabs(a) > 1.0)
CPPUNIT_ASSERT(fabs(a - b) <= fabs(a) * 1e-11);
CPPUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(a) * 1e-11);
else
CPPUNIT_ASSERT(fabs(a - b) <= fabs(f) * 1e-11);
CPPUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(f) * 1e-11);
}

for (int i = -10000; i < 10000; i++)
@@ -112,11 +112,11 @@ public:
double a = __builtin_tan(f);
double b = lol_tan(f);
if (fabs(a) > 1e4)
CPPUNIT_ASSERT(fabs(a - b) <= fabs(a) * fabs(a) * 1e-11);
CPPUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(a) * fabs(a) * 1e-11);
else if (fabs(a) > 1.0)
CPPUNIT_ASSERT(fabs(a - b) <= fabs(a) * 1e-11);
CPPUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(a) * 1e-11);
else
CPPUNIT_ASSERT(fabs(a - b) <= fabs(f) * 1e-11);
CPPUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(f) * 1e-11);
}
}
};


Loading…
Cancel
Save