summaryrefslogtreecommitdiff
path: root/sw/qa
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2014-03-03 18:27:00 +0100
committerStephan Bergmann <sbergman@redhat.com>2014-03-03 18:36:55 +0100
commitb2371492dfd5c8003f89ed8acf3dbc690d6af8d0 (patch)
tree876a32c415fa06d41a51a2a4a9cc16b1e97bdf76 /sw/qa
parent768ea2924680fc4beb75a782cb0faf26695fee53 (diff)
Use cstdlib std::abs instead of stdlib.h abs
...because the latter lacks the abs(long) overload in some popular environments, cf. <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60401> "stdlib.h does not provide abs(long) overload." Similarly, stdlib.h lacks the abs(float), abs(double), abs(long double) overloads compared to cmath there, whose use was apparently intended in sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx. Rewrote that to use CPPUNIT_ASSERT_DOUBLES_EQUAL instead, which revealed that the comparisons need rather large deltas of .1 resp. .2 (which the original code hid with an implicit conversion to integral type, thus using an effective delta of 1). Discovered with -Wabsolute-value ("absolute value function 'abs' given an argument of type 'long' but has parameter of type 'int' which may cause truncation of value") recently introduced on Clang trunk towards 3.5. Change-Id: I4c41575ffdccb2944498b662bd3a53fd510cb0c0
Diffstat (limited to 'sw/qa')
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx8
1 files changed, 4 insertions, 4 deletions
diff --git a/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx
index 8dc0ef5d85fd..e9ef92837d4a 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx
@@ -517,22 +517,22 @@ DECLARE_OOXMLEXPORT_TEST(testFdo70838, "fdo70838.docx")
if( aStyleCommandName.equals( "margin-left" ) )
{
float fValue = aStyleCommandValue.getToken( 0, 'p' ).toFloat();
- CPPUNIT_ASSERT_EQUAL(0, abs(97.6 - fValue));
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(97.6, fValue, 0.1);
}
else if( aStyleCommandName.equals( "margin-top" ) )
{
float fValue = aStyleCommandValue.getToken( 0, 'p' ).toFloat();
- CPPUNIT_ASSERT_EQUAL(0, abs(165 - fValue));
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(165.0, fValue, 0.2);
}
else if( aStyleCommandName.equals( "width" ) )
{
float fValue = aStyleCommandValue.getToken( 0, 'p' ).toFloat();
- CPPUNIT_ASSERT_EQUAL(0, abs(283.4 - fValue));
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(283.4, fValue, 0.1);
}
else if( aStyleCommandName.equals( "height" ) )
{
float fValue = aStyleCommandValue.getToken( 0, 'p' ).toFloat();
- CPPUNIT_ASSERT_EQUAL(0, abs(141.7 - fValue));
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(141.7, fValue, 0.1);
}
} while( nextTokenPos != -1 );