[Libreoffice-commits] core.git: basegfx/test sdext/source test/source vcl/qa

Stephan Bergmann sbergman at redhat.com
Thu Oct 6 14:38:24 UTC 2016


 basegfx/test/basegfx2d.cxx             |   81 ++++++++++++++++++++-------------
 basegfx/test/basegfxtools.cxx          |    3 -
 sdext/source/pdfimport/test/tests.cxx  |   11 ++--
 test/source/sheet/xdatapilottable2.cxx |    3 -
 vcl/qa/cppunit/mapmode.cxx             |    8 +--
 5 files changed, 63 insertions(+), 43 deletions(-)

New commits:
commit 187d7f8f527217c1f958feec7d3a83f866a8e477
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Thu Oct 6 16:34:21 2016 +0200

    CPPUNIT_ASSERT[_DOUBLES]_EQUAL
    
    Change-Id: I417cea926abcc511e74a090ee90a851c138ac0c0

diff --git a/basegfx/test/basegfx2d.cxx b/basegfx/test/basegfx2d.cxx
index fbc0930..502f784 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 7d27fa5..dc0dfb9 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
diff --git a/sdext/source/pdfimport/test/tests.cxx b/sdext/source/pdfimport/test/tests.cxx
index f24a8b4..091f643 100644
--- a/sdext/source/pdfimport/test/tests.cxx
+++ b/sdext/source/pdfimport/test/tests.cxx
@@ -239,12 +239,11 @@ namespace
             }
             else
             {
-                CPPUNIT_ASSERT_MESSAGE( "Dash array consists of four entries",
-                                        rContext.DashArray.size() == 4 &&
-                                        rtl::math::approxEqual(rContext.DashArray[0],14.3764) &&
-                                        rContext.DashArray[0] == rContext.DashArray[1] &&
-                                        rContext.DashArray[1] == rContext.DashArray[2] &&
-                                        rContext.DashArray[2] == rContext.DashArray[3] );
+                CPPUNIT_ASSERT_EQUAL_MESSAGE( "Dash array consists of four entries", std::vector<double>::size_type(4), rContext.DashArray.size());
+                CPPUNIT_ASSERT_DOUBLES_EQUAL( 14.3764, rContext.DashArray[0], 1E-12 );
+                CPPUNIT_ASSERT_DOUBLES_EQUAL( rContext.DashArray[0], rContext.DashArray[1], 1E-12 );
+                CPPUNIT_ASSERT_DOUBLES_EQUAL( rContext.DashArray[1], rContext.DashArray[2], 1E-12 );
+                CPPUNIT_ASSERT_DOUBLES_EQUAL( rContext.DashArray[2], rContext.DashArray[3], 1E-12 );
 
                 CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "Line color is black", 1.0, rContext.LineColor.Alpha, 0.00000001);
                 CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "Line color is black", 0.0, rContext.LineColor.Blue, 0.00000001);
diff --git a/test/source/sheet/xdatapilottable2.cxx b/test/source/sheet/xdatapilottable2.cxx
index 7be89cb..235fa50 100644
--- a/test/source/sheet/xdatapilottable2.cxx
+++ b/test/source/sheet/xdatapilottable2.cxx
@@ -88,8 +88,7 @@ void XDataPilotTable2::testGetDrillDownData()
             }
         }
 
-        std::cout << "Sum: " << sum << "; nVal: " << nVal << std::endl;
-        CPPUNIT_ASSERT(sum == nVal);
+        CPPUNIT_ASSERT_DOUBLES_EQUAL(nVal, sum, 1E-12);
     }
 
 
diff --git a/vcl/qa/cppunit/mapmode.cxx b/vcl/qa/cppunit/mapmode.cxx
index d4c7e82..94e6d4b 100644
--- a/vcl/qa/cppunit/mapmode.cxx
+++ b/vcl/qa/cppunit/mapmode.cxx
@@ -45,17 +45,17 @@ void VclMapModeTest::testMultiplier()
     aMapMode.SetMapUnit( MapUnit::MapCM );
     CPPUNIT_ASSERT_MESSAGE( "Map mode is MapUnit::MapCM, multiplier should be 1000", aMapMode.GetUnitMultiplier() == 1000 );
     aMapMode.SetMapUnit( MapUnit::Map1000thInch );
-    CPPUNIT_ASSERT_MESSAGE( "Map mode is MapUnit::Map1000thInch, multiplier should be 2.54", aMapMode.GetUnitMultiplier() == 2.54 );
+    CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "Map mode is MapUnit::Map1000thInch, multiplier should be 2.54", 2.54, aMapMode.GetUnitMultiplier(), 1E-12 );
     aMapMode.SetMapUnit( MapUnit::Map100thInch );
-    CPPUNIT_ASSERT_MESSAGE( "Map mode is MapUnit::Map100thInch, multiplier should be 2.54", aMapMode.GetUnitMultiplier() == 25.4 );
+    CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "Map mode is MapUnit::Map100thInch, multiplier should be 2.54", 25.4, aMapMode.GetUnitMultiplier(), 1E-12 );
     aMapMode.SetMapUnit( MapUnit::Map10thInch );
     CPPUNIT_ASSERT_MESSAGE( "Map mode is MapUnit::Map10thInch, multiplier should be 254", aMapMode.GetUnitMultiplier() == 254 );
     aMapMode.SetMapUnit( MapUnit::MapInch );
     CPPUNIT_ASSERT_MESSAGE( "Map mode is MapUnit::MapInch, multiplier should be 2540", aMapMode.GetUnitMultiplier() == 2540 );
     aMapMode.SetMapUnit( MapUnit::MapTwip );
-    CPPUNIT_ASSERT_MESSAGE( "Map mode is MapUnit::MapTwip, multiplier should be 1.76388889", aMapMode.GetUnitMultiplier() == 1.76388889 );
+    CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "Map mode is MapUnit::MapTwip, multiplier should be 1.76388889", 1.76388889, aMapMode.GetUnitMultiplier(), 1E-12 );
     aMapMode.SetMapUnit( MapUnit::MapPoint );
-    CPPUNIT_ASSERT_MESSAGE( "Map mode is MapUnit::MapPoint, multiplier should be 35.27777778", aMapMode.GetUnitMultiplier() == 35.27777778 );
+    CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "Map mode is MapUnit::MapPoint, multiplier should be 35.27777778", 35.27777778, aMapMode.GetUnitMultiplier(), 1E-12 );
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(VclMapModeTest);


More information about the Libreoffice-commits mailing list