Changeset 1257 for trunk/test
 Timestamp:
 Apr 21, 2012, 6:58:26 PM (8 years ago)
 Location:
 trunk/test
 Files:

 1 added
 3 edited
Legend:
 Unmodified
 Added
 Removed

trunk/test/Makefile.am
r1139 r1257 23 23 24 24 testsuite_SOURCES = testsuite.cpp \ 25 unit/vector.cpp unit/ half.cpp unit/trig.cpp unit/build.cpp \26 unit/ real.cpp unit/image.cpp unit/quat.cpp unit/cmplx.cpp25 unit/vector.cpp unit/matrix.cpp unit/half.cpp unit/trig.cpp \ 26 unit/build.cpp unit/real.cpp unit/image.cpp unit/quat.cpp unit/cmplx.cpp 27 27 testsuite_CPPFLAGS = @LOL_CFLAGS@ @PIPI_CFLAGS@ 28 28 testsuite_LDFLAGS = $(top_builddir)/src/liblol.a @LOL_LIBS@ @PIPI_LIBS@ 
trunk/test/benchmark/vector.cpp
r1139 r1257 53 53 timer.GetMs(); 54 54 for (size_t i = 0; i < MATRIX_TABLE_SIZE; i++) 55 pf[i] = pm[i].det();55 pf[i] = determinant(pm[i]); 56 56 result[1] += timer.GetMs(); 57 57 … … 71 71 timer.GetMs(); 72 72 for (size_t i = 0; i < MATRIX_TABLE_SIZE; i++) 73 pm[i] = pm[i].invert();73 pm[i] = inverse(pm[i]); 74 74 result[4] += timer.GetMs(); 75 75 } 
trunk/test/unit/vector.cpp
r1139 r1257 21 21 LOLUNIT_FIXTURE(VectorTest) 22 22 { 23 void SetUp() 24 { 25 identity = mat4(1.0f); 26 triangular = mat4(vec4(1.0f, 0.0f, 0.0f, 0.0f), 27 vec4(7.0f, 2.0f, 0.0f, 0.0f), 28 vec4(1.0f, 5.0f, 3.0f, 0.0f), 29 vec4(8.0f, 9.0f, 2.0f, 4.0f)); 30 invertible = mat4(vec4( 1.0f, 1.0f, 2.0f, 1.0f), 31 vec4(2.0f, 1.0f, 2.0f, 2.0f), 32 vec4( 4.0f, 2.0f, 5.0f, 4.0f), 33 vec4( 5.0f, 3.0f, 7.0f, 6.0f)); 34 } 23 void SetUp() {} 35 24 36 25 void TearDown() {} … … 136 125 LOLUNIT_ASSERT_EQUAL(a3, a1); 137 126 } 138 139 LOLUNIT_TEST(MatrixDeterminant)140 {141 float d1 = triangular.det();142 LOLUNIT_ASSERT_EQUAL(d1, 24.0f);143 float d2 = invertible.det();144 LOLUNIT_ASSERT_EQUAL(d2, 1.0f);145 }146 147 LOLUNIT_TEST(MatrixMultiplication)148 {149 mat4 m0 = identity;150 mat4 m1 = identity;151 mat4 m2 = m0 * m1;152 153 LOLUNIT_ASSERT_EQUAL(m2[0][0], 1.0f);154 LOLUNIT_ASSERT_EQUAL(m2[1][0], 0.0f);155 LOLUNIT_ASSERT_EQUAL(m2[2][0], 0.0f);156 LOLUNIT_ASSERT_EQUAL(m2[3][0], 0.0f);157 158 LOLUNIT_ASSERT_EQUAL(m2[0][1], 0.0f);159 LOLUNIT_ASSERT_EQUAL(m2[1][1], 1.0f);160 LOLUNIT_ASSERT_EQUAL(m2[2][1], 0.0f);161 LOLUNIT_ASSERT_EQUAL(m2[3][1], 0.0f);162 163 LOLUNIT_ASSERT_EQUAL(m2[0][2], 0.0f);164 LOLUNIT_ASSERT_EQUAL(m2[1][2], 0.0f);165 LOLUNIT_ASSERT_EQUAL(m2[2][2], 1.0f);166 LOLUNIT_ASSERT_EQUAL(m2[3][2], 0.0f);167 168 LOLUNIT_ASSERT_EQUAL(m2[0][3], 0.0f);169 LOLUNIT_ASSERT_EQUAL(m2[1][3], 0.0f);170 LOLUNIT_ASSERT_EQUAL(m2[2][3], 0.0f);171 LOLUNIT_ASSERT_EQUAL(m2[3][3], 1.0f);172 }173 174 LOLUNIT_TEST(MatrixInverse)175 {176 mat4 m0 = invertible;177 mat4 m1 = m0.invert();178 179 mat4 m2 = m0 * m1;180 181 LOLUNIT_ASSERT_EQUAL(m2[0][0], 1.0f);182 LOLUNIT_ASSERT_EQUAL(m2[1][0], 0.0f);183 LOLUNIT_ASSERT_EQUAL(m2[2][0], 0.0f);184 LOLUNIT_ASSERT_EQUAL(m2[3][0], 0.0f);185 186 LOLUNIT_ASSERT_EQUAL(m2[0][1], 0.0f);187 LOLUNIT_ASSERT_EQUAL(m2[1][1], 1.0f);188 LOLUNIT_ASSERT_EQUAL(m2[2][1], 0.0f);189 LOLUNIT_ASSERT_EQUAL(m2[3][1], 0.0f);190 191 LOLUNIT_ASSERT_EQUAL(m2[0][2], 0.0f);192 LOLUNIT_ASSERT_EQUAL(m2[1][2], 0.0f);193 LOLUNIT_ASSERT_EQUAL(m2[2][2], 1.0f);194 LOLUNIT_ASSERT_EQUAL(m2[3][2], 0.0f);195 196 LOLUNIT_ASSERT_EQUAL(m2[0][3], 0.0f);197 LOLUNIT_ASSERT_EQUAL(m2[1][3], 0.0f);198 LOLUNIT_ASSERT_EQUAL(m2[2][3], 0.0f);199 LOLUNIT_ASSERT_EQUAL(m2[3][3], 1.0f);200 }201 202 mat4 triangular, identity, invertible;203 127 }; 204 128
Note: See TracChangeset
for help on using the changeset viewer.