Browse Source

test: add a unit test for the recent vector promotion problem.

legacy
Sam Hocevar sam 13 years ago
parent
commit
0328a6dfa3
1 changed files with 21 additions and 0 deletions
  1. +21
    -0
      test/matrix.cpp

+ 21
- 0
test/matrix.cpp View File

@@ -28,6 +28,7 @@ class MatrixTest : public CppUnit::TestCase
CPPUNIT_TEST(test_vec_eq); CPPUNIT_TEST(test_vec_eq);
CPPUNIT_TEST(test_vec_lt); CPPUNIT_TEST(test_vec_lt);
CPPUNIT_TEST(test_vec_unary); CPPUNIT_TEST(test_vec_unary);
CPPUNIT_TEST(test_vec_cast);
CPPUNIT_TEST(test_mat_det); CPPUNIT_TEST(test_mat_det);
CPPUNIT_TEST(test_mat_mul); CPPUNIT_TEST(test_mat_mul);
CPPUNIT_TEST(test_mat_inv); CPPUNIT_TEST(test_mat_inv);
@@ -132,6 +133,26 @@ public:
CPPUNIT_ASSERT(-a == b); CPPUNIT_ASSERT(-a == b);
} }


void test_vec_cast()
{
vec2 a1(1.0f, 3.0f);

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(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(a3 == a1);
}

void test_mat_det() void test_mat_det()
{ {
float d1 = triangular.det(); float d1 = triangular.det();


Loading…
Cancel
Save