--- trunk/OOPSE-3.0/test/math/RectMatrixTestCase.cpp 2004/10/19 04:34:35 1597 +++ trunk/OOPSE-3.0/test/math/RectMatrixTestCase.cpp 2004/10/25 22:46:19 1644 @@ -166,6 +166,15 @@ void RectMatrixTestCase::testConstructor(){ tmp4 = tmp4; CPPUNIT_ASSERT(tmp4 == m2); + double tmp5[4]; + tmp5[0] = 1.0; + tmp5[1] = 1.0; + tmp5[2] = 3.0; + tmp5[3] = 1.0; + + RMat2x2 tmp6(tmp5); + CPPUNIT_ASSERT(tmp6 == m1); + } @@ -237,6 +246,7 @@ void RectMatrixTestCase::testDiv() { CPPUNIT_ASSERT(m1 / 2.0 * 2.0 == m1); + } void RectMatrixTestCase::testAccessEntries(){ @@ -250,8 +260,9 @@ void RectMatrixTestCase::testRowColOperations() { //test getRow row = e.getRow(0); - CPPUNIT_ASSERT(row[0] == 2.0 && row[1] == 4.0 && row[2] == 1.0); - + CPPUNIT_ASSERT_DOUBLES_EQUAL(row[0], 2.0, oopse::epsilon); + CPPUNIT_ASSERT_DOUBLES_EQUAL(row[1], 4.0, oopse::epsilon); + CPPUNIT_ASSERT_DOUBLES_EQUAL(row[2], 1.0, oopse::epsilon); //test setRow row[0] = 2.0; row[1] = 4.0; @@ -269,8 +280,9 @@ void RectMatrixTestCase::testRowColOperations() { //test getCol col = e.getColum(1); - CPPUNIT_ASSERT(col[0] == 4.0 && col[1] == 0.0 && col[2] == 6.0); - + CPPUNIT_ASSERT_DOUBLES_EQUAL(col[0], 4.0, oopse::epsilon); + CPPUNIT_ASSERT_DOUBLES_EQUAL(col[1], 0.0, oopse::epsilon); + CPPUNIT_ASSERT_DOUBLES_EQUAL(col[2], 6.0, oopse::epsilon); //test setCol col[0] = 2.0; col[1] = 0.0; @@ -311,7 +323,20 @@ void RectMatrixTestCase::testRowColOperations() { s.swapColum(0, 1); CPPUNIT_ASSERT(s == e); - + + double* p = s.getArrayPointer(); + + p[0] = 2.0; + p[1] = 4.0; + p[2] = 1.0; + p[3] = 0.0; + p[4] = 6.0; + p[5] = 5.0; + p[6] = 0.0; + p[7] = 0.0; + p[8] = 3.0; + + CPPUNIT_ASSERT(s == f); } void RectMatrixTestCase::testOtherMemberFunctions(){ @@ -319,4 +344,14 @@ void RectMatrixTestCase::testOtherMemberFunctions(){ CPPUNIT_ASSERT((a.transpose()).transpose() == a); CPPUNIT_ASSERT(a.transpose() == b); + + //test getArray + + double tmp[4]; + m4.getArray(tmp); + CPPUNIT_ASSERT_DOUBLES_EQUAL(tmp[0], -1.0, oopse::epsilon); + CPPUNIT_ASSERT_DOUBLES_EQUAL(tmp[1], -1.0, oopse::epsilon); + CPPUNIT_ASSERT_DOUBLES_EQUAL(tmp[2], -3.0, oopse::epsilon); + CPPUNIT_ASSERT_DOUBLES_EQUAL(tmp[3], -1.0, oopse::epsilon); + }