Kaydet (Commit) 187d7f8f authored tarafından Stephan Bergmann's avatar Stephan Bergmann

CPPUNIT_ASSERT[_DOUBLES]_EQUAL

Change-Id: I417cea926abcc511e74a090ee90a851c138ac0c0
üst f5e2a466
......@@ -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
......
......@@ -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
......
......@@ -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);
......
......@@ -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);
}
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment