diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2016-10-06 16:34:21 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2016-10-06 16:35:53 +0200 |
commit | 187d7f8f527217c1f958feec7d3a83f866a8e477 (patch) | |
tree | 501ec90fe10c8d67fe584be95fb03b976bd152e5 /basegfx/test | |
parent | f5e2a466066053d70e5ff6a0cc1857910b01a9b6 (diff) |
CPPUNIT_ASSERT[_DOUBLES]_EQUAL
Change-Id: I417cea926abcc511e74a090ee90a851c138ac0c0
Diffstat (limited to 'basegfx/test')
-rw-r--r-- | basegfx/test/basegfx2d.cxx | 81 | ||||
-rw-r--r-- | basegfx/test/basegfxtools.cxx | 3 |
2 files changed, 53 insertions, 31 deletions
diff --git a/basegfx/test/basegfx2d.cxx b/basegfx/test/basegfx2d.cxx index fbc093052a69..502f7844c7f4 100644 --- a/basegfx/test/basegfx2d.cxx +++ b/basegfx/test/basegfx2d.cxx @@ -440,37 +440,57 @@ public: { B2DHomMatrix mat; mat.rotate(90*F_PI180); - CPPUNIT_ASSERT_MESSAGE("rotate pi/2 yields exact matrix", - mat.get(0,0) == 0.0 && - mat.get(0,1) == -1.0 && - mat.get(0,2) == 0.0 && - mat.get(1,0) == 1.0 && - mat.get(1,1) == 0.0 && - mat.get(1,2) == 0.0); + CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( + "rotate pi/2 yields exact matrix", 0.0, mat.get(0,0), 1E-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( + "rotate pi/2 yields exact matrix", -1.0, mat.get(0,1), 1E-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( + "rotate pi/2 yields exact matrix", 0.0, mat.get(0,2), 1E-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( + "rotate pi/2 yields exact matrix", 1.0, mat.get(1,0), 1E-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( + "rotate pi/2 yields exact matrix", 0.0, mat.get(1,1), 1E-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( + "rotate pi/2 yields exact matrix", 0.0, mat.get(1,2), 1E-12); mat.rotate(90*F_PI180); - CPPUNIT_ASSERT_MESSAGE("rotate pi yields exact matrix", - mat.get(0,0) == -1.0 && - mat.get(0,1) == 0.0 && - mat.get(0,2) == 0.0 && - mat.get(1,0) == 0.0 && - mat.get(1,1) == -1.0 && - mat.get(1,2) == 0.0); + CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( + "rotate pi yields exact matrix", -1.0, mat.get(0,0), 1E-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( + "rotate pi yields exact matrix", 0.0, mat.get(0,1), 1E-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( + "rotate pi yields exact matrix", 0.0, mat.get(0,2), 1E-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( + "rotate pi yields exact matrix", 0.0, mat.get(1,0), 1E-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( + "rotate pi yields exact matrix", -1.0, mat.get(1,1), 1E-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( + "rotate pi yields exact matrix", 0.0, mat.get(1,2), 1E-12); mat.rotate(90*F_PI180); - CPPUNIT_ASSERT_MESSAGE("rotate 3/2 pi yields exact matrix", - mat.get(0,0) == 0.0 && - mat.get(0,1) == 1.0 && - mat.get(0,2) == 0.0 && - mat.get(1,0) == -1.0 && - mat.get(1,1) == 0.0 && - mat.get(1,2) == 0.0); + CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( + "rotate 3/2 pi yields exact matrix", 0.0, mat.get(0,0), 1E-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( + "rotate 3/2 pi yields exact matrix", 1.0, mat.get(0,1), 1E-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( + "rotate 3/2 pi yields exact matrix", 0.0, mat.get(0,2), 1E-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( + "rotate 3/2 pi yields exact matrix", -1.0, mat.get(1,0), 1E-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( + "rotate 3/2 pi yields exact matrix", 0.0, mat.get(1,1), 1E-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( + "rotate 3/2 pi yields exact matrix", 0.0, mat.get(1,2), 1E-12); mat.rotate(90*F_PI180); - CPPUNIT_ASSERT_MESSAGE("rotate 2 pi yields exact matrix", - mat.get(0,0) == 1.0 && - mat.get(0,1) == 0.0 && - mat.get(0,2) == 0.0 && - mat.get(1,0) == 0.0 && - mat.get(1,1) == 1.0 && - mat.get(1,2) == 0.0); + CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( + "rotate 2 pi yields exact matrix", 1.0, mat.get(0,0), 1E-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( + "rotate 2 pi yields exact matrix", 0.0, mat.get(0,1), 1E-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( + "rotate 2 pi yields exact matrix", 0.0, mat.get(0,2), 1E-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( + "rotate 2 pi yields exact matrix", 0.0, mat.get(1,0), 1E-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( + "rotate 2 pi yields exact matrix", 1.0, mat.get(1,1), 1E-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( + "rotate 2 pi yields exact matrix", 0.0, mat.get(1,2), 1E-12); } void translate() @@ -661,9 +681,10 @@ public: double fDRot; double fDShX; aTest.decompose(aDScale, aDTrans, fDRot, fDShX); - CPPUNIT_ASSERT_MESSAGE("decompose: error test J1", aDScale.getX() == 6425 && aDScale.getY() == 3938); + CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("decompose: error test J1", 6425.0, aDScale.getX(), 1E-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("decompose: error test J1", 3938.0, aDScale.getY(), 1E-12); CPPUNIT_ASSERT_MESSAGE("decompose: error test J1", aDTrans.getX() == 10482 && aDTrans.getY() == 4921); - CPPUNIT_ASSERT_MESSAGE("decompose: error test J1", fDRot == 180*F_PI180); + CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("decompose: error test J1", 180*F_PI180, fDRot, 1E-12 ); } // Change the following lines only, if you add, remove or rename diff --git a/basegfx/test/basegfxtools.cxx b/basegfx/test/basegfxtools.cxx index 7d27fa50eb44..dc0dfb9152f9 100644 --- a/basegfx/test/basegfxtools.cxx +++ b/basegfx/test/basegfxtools.cxx @@ -73,7 +73,8 @@ public: CPPUNIT_ASSERT_MESSAGE("0.51", nIndex==1 && fTools::equal(fAlpha,1.0)); std::tie(nIndex,fAlpha) = maKeyStops.lerp(1.0); - CPPUNIT_ASSERT_MESSAGE("0.51", nIndex==1 && fAlpha==1.0); + CPPUNIT_ASSERT_EQUAL_MESSAGE("0.51", std::ptrdiff_t(1), nIndex); + CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("0.51", 1.0, fAlpha, 1E-12); } // Change the following lines only, if you add, remove or rename |