[Libreoffice-commits] core.git: 3 commits - sax/CppunitTest_sax.mk sax/qa sax/source
Stephan Bergmann
sbergman at redhat.com
Tue Dec 17 07:57:07 PST 2013
sax/CppunitTest_sax.mk | 10 +++++-----
sax/qa/cppunit/test_converter.cxx | 17 ++++++++---------
sax/source/tools/converter.cxx | 10 +++++++---
3 files changed, 20 insertions(+), 17 deletions(-)
New commits:
commit acb9da3d4a0d04be447d942da2ea197aa12349e3
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Tue Dec 17 16:51:35 2013 +0100
Fix naming
Change-Id: Ia7c62d57c56a27e097dbe252b6c6cac8fba7ace5
diff --git a/sax/CppunitTest_sax.mk b/sax/CppunitTest_sax.mk
index 0747522..62624b9 100644
--- a/sax/CppunitTest_sax.mk
+++ b/sax/CppunitTest_sax.mk
@@ -7,16 +7,16 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
-$(eval $(call gb_CppunitTest_CppunitTest,sax_cpputest))
+$(eval $(call gb_CppunitTest_CppunitTest,sax))
-$(eval $(call gb_CppunitTest_use_api,sax_cpputest,\
+$(eval $(call gb_CppunitTest_use_api,sax,\
offapi \
udkapi \
))
-$(eval $(call gb_CppunitTest_use_external,sax_cpputest,boost_headers))
+$(eval $(call gb_CppunitTest_use_external,sax,boost_headers))
-$(eval $(call gb_CppunitTest_use_libraries,sax_cpputest, \
+$(eval $(call gb_CppunitTest_use_libraries,sax, \
sax \
sal \
comphelper \
@@ -24,7 +24,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sax_cpputest, \
$(gb_UWINAPI) \
))
-$(eval $(call gb_CppunitTest_add_exception_objects,sax_cpputest, \
+$(eval $(call gb_CppunitTest_add_exception_objects,sax, \
sax/qa/cppunit/test_converter \
))
commit 695671eb18674ea58103093b9cf31a31afe8d2fd
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Tue Dec 17 16:46:17 2013 +0100
Avoid inaccurate floating-point computations
...otherwise at least my --disable-dbgutil --disable-debug Linux x86_64 build
failed the CppunitTest_sax_cpputest with 8999999 vs. 9000000 nanoseconds.
Change-Id: I05e0febf413f9f9e01227a0cc4e0f46a5243fe61
diff --git a/sax/source/tools/converter.cxx b/sax/source/tools/converter.cxx
index b5c9934..3ebe40c 100644
--- a/sax/source/tools/converter.cxx
+++ b/sax/source/tools/converter.cxx
@@ -1122,9 +1122,13 @@ bool Converter::convertDuration(util::Duration& rDuration,
{
if (-1 != nTemp)
{
- const sal_Int32 nDigits = std::min<sal_Int32>(nPos - nStart, 9);
- OSL_ENSURE(nDigits > 0, "bad code monkey: negative digits");
- nNanoSeconds=static_cast<double>(nTemp)*(1000000000.0/pow(10.0,nDigits));
+ nNanoSeconds = nTemp;
+ sal_Int32 nDigits = nPos - nStart;
+ assert(nDigits >= 0 && nDigits <= 9);
+ for (; nDigits < 9; ++nDigits)
+ {
+ nNanoSeconds *= 10;
+ }
nTemp=-1;
if ('S' == string[nPos])
{
commit 0b2bc82f3cef534d8cab60d8c48a4113abce38cd
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Tue Dec 17 16:45:39 2013 +0100
Improve CPPUNIT_ASSERTs
Change-Id: I971602ce562ae0e11be5ac7b4d1eefbd342b625c
diff --git a/sax/qa/cppunit/test_converter.cxx b/sax/qa/cppunit/test_converter.cxx
index 7145e5e..cbc3ae0 100644
--- a/sax/qa/cppunit/test_converter.cxx
+++ b/sax/qa/cppunit/test_converter.cxx
@@ -86,14 +86,6 @@ void ConverterTest::tearDown()
{
}
-static bool eqDuration(util::Duration a, util::Duration b) {
- return a.Years == b.Years && a.Months == b.Months && a.Days == b.Days
- && a.Hours == b.Hours && a.Minutes == b.Minutes
- && a.Seconds == b.Seconds
- && a.NanoSeconds == b.NanoSeconds
- && a.Negative == b.Negative;
-}
-
static void doTest(util::Duration const & rid, char const*const pis,
char const*const i_pos = 0)
{
@@ -104,7 +96,14 @@ static void doTest(util::Duration const & rid, char const*const pis,
bool bSuccess = Converter::convertDuration(od, is);
SAL_INFO("sax.cppunit","" << (od.Negative ? "-" : "+") << " " << od.Years << "Y " << od.Months << "M " << od.Days << "D " << od.Hours << "H " << od.Minutes << "M " << od.Seconds << "S " << od.NanoSeconds << "n");
CPPUNIT_ASSERT(bSuccess);
- CPPUNIT_ASSERT(eqDuration(rid, od));
+ CPPUNIT_ASSERT_EQUAL(rid.Years, od.Years);
+ CPPUNIT_ASSERT_EQUAL(rid.Months, od.Months);
+ CPPUNIT_ASSERT_EQUAL(rid.Days, od.Days);
+ CPPUNIT_ASSERT_EQUAL(rid.Hours, od.Hours);
+ CPPUNIT_ASSERT_EQUAL(rid.Minutes, od.Minutes);
+ CPPUNIT_ASSERT_EQUAL(rid.Seconds, od.Seconds);
+ CPPUNIT_ASSERT_EQUAL(rid.NanoSeconds, od.NanoSeconds);
+ CPPUNIT_ASSERT_EQUAL(rid.Negative, od.Negative);
OUStringBuffer buf;
Converter::convertDuration(buf, od);
SAL_INFO("sax.cppunit","" << buf.toString());
More information about the Libreoffice-commits
mailing list