diff options
author | Carsten Driesner <cd@openoffice.org> | 2010-11-15 13:10:36 +0100 |
---|---|---|
committer | Carsten Driesner <cd@openoffice.org> | 2010-11-15 13:10:36 +0100 |
commit | 14b3f70af24aa72b9ddb380d4674d8126ebb20df (patch) | |
tree | 6c815609de903dc6d5e76a0816ee52dbd212cc39 /sal | |
parent | d0b6725a60a3ca5fa8ca7d2e55a51f9ba8720f85 (diff) | |
parent | 1ed36293dcf8c363b3889c83a7eb7898a8b131d0 (diff) |
Rebase to DEV300m93
Diffstat (limited to 'sal')
-rw-r--r-- | sal/inc/osl/diagnose.h | 10 | ||||
-rw-r--r-- | sal/inc/rtl/math.h | 8 | ||||
-rw-r--r-- | sal/osl/unx/file_misc.cxx | 57 | ||||
-rw-r--r-- | sal/prj/build.lst | 1 | ||||
-rw-r--r-- | sal/qa/OStringBuffer/makefile.mk | 2 | ||||
-rw-r--r-- | sal/qa/osl/process/makefile.mk | 2 | ||||
-rw-r--r-- | sal/qa/osl/profile/makefile.mk | 1 | ||||
-rwxr-xr-x | sal/qa/rtl/alloc/makefile.mk | 2 | ||||
-rwxr-xr-x | sal/qa/rtl/crc32/makefile.mk | 2 | ||||
-rw-r--r-- | sal/qa/rtl/digest/makefile.mk | 2 | ||||
-rw-r--r-- | sal/qa/rtl/doublelock/makefile.mk | 2 | ||||
-rw-r--r-- | sal/qa/rtl/locale/makefile.mk | 2 | ||||
-rw-r--r-- | sal/qa/rtl/math/export.exp | 1 | ||||
-rw-r--r-- | sal/qa/rtl/math/makefile.mk | 84 | ||||
-rw-r--r-- | sal/qa/rtl/math/rtl_math.cxx | 626 | ||||
-rw-r--r-- | sal/qa/rtl/math/rtl_old_testint64.cxx | 122 | ||||
-rw-r--r-- | sal/qa/rtl/math/test-rtl-math.cxx | 76 | ||||
-rw-r--r-- | sal/qa/rtl/math/test_rtl_math.cxx | 674 | ||||
-rw-r--r-- | sal/qa/rtl/random/makefile.mk | 2 | ||||
-rw-r--r-- | sal/qa/rtl_strings/makefile.mk | 1 | ||||
-rw-r--r-- | sal/rtl/source/math.cxx | 2 | ||||
-rw-r--r-- | sal/systools/win32/kill/kill.cxx | 2 | ||||
-rw-r--r-- | sal/textenc/convertiscii.tab | 2 | ||||
-rw-r--r-- | sal/textenc/tencinfo.c | 5 |
24 files changed, 124 insertions, 1564 deletions
diff --git a/sal/inc/osl/diagnose.h b/sal/inc/osl/diagnose.h index 055a7971e7b6..033b24c84360 100644 --- a/sal/inc/osl/diagnose.h +++ b/sal/inc/osl/diagnose.h @@ -78,15 +78,7 @@ pfunc_osl_printDetailedDebugMessage SAL_CALL osl_setDetailedDebugMessageFunc( pf #define OSL_THIS_FILE __FILE__ /* the macro OSL_THIS_FUNC is intended to be an office internal macro for now */ -#ifdef __func__ -#define OSL_THIS_FUNC __func__ -#elifdef __PRETTY_FUNCTION__ -#define OSL_THIS_FUNC __PRETTY_FUNCTION__ -#elifdef __FUNCTION__ -#define OSL_THIS_FUNC __FUNCTION__ -#else -#define OSL_THIS_FUNC " " -#endif +#define OSL_THIS_FUNC "<unknown>" /* the macro OSL_TO_STRING is intended to be an office internal macro for now */ #define OSL_TO_STRING( x ) #x diff --git a/sal/inc/rtl/math.h b/sal/inc/rtl/math.h index 985ce700b049..fa81108df29f 100644 --- a/sal/inc/rtl/math.h +++ b/sal/inc/rtl/math.h @@ -319,7 +319,9 @@ void SAL_CALL rtl_math_doubleToUString(rtl_uString ** pResult, @param pParsedEnd If non-null, returns one past the position of the last character parsed away. Thus if [pBegin..pEnd) only contains the numerical string to be - parsed, *pParsedEnd == pEnd on return. + parsed, *pParsedEnd == pEnd on return. If no numerical (sub-)string is + found, *pParsedEnd == pBegin on return, even if there was leading + whitespace. */ double SAL_CALL rtl_math_stringToDouble( sal_Char const * pBegin, sal_Char const * pEnd, sal_Char cDecSeparator, @@ -357,7 +359,9 @@ double SAL_CALL rtl_math_stringToDouble( @param pParsedEnd If non-null, returns one past the position of the last character parsed away. Thus if [pBegin..pEnd) only contains the numerical string to be - parsed, *pParsedEnd == pEnd on return. + parsed, *pParsedEnd == pEnd on return. If no numerical (sub-)string is + found, *pParsedEnd == pBegin on return, even if there was leading + whitespace. */ double SAL_CALL rtl_math_uStringToDouble( sal_Unicode const * pBegin, sal_Unicode const * pEnd, diff --git a/sal/osl/unx/file_misc.cxx b/sal/osl/unx/file_misc.cxx index 331b91cb1626..452d3eb2db70 100644 --- a/sal/osl/unx/file_misc.cxx +++ b/sal/osl/unx/file_misc.cxx @@ -1022,66 +1022,31 @@ static int oslDoCopyFile(const sal_Char* pszSourceFileName, const sal_Char* pszD return nRet; } - /* HACK: because memory mapping fails on various - platforms if the size of the source file is 0 byte */ - if (0 == nSourceSize) - { - close(SourceFileFD); - close(DestFileFD); - return 0; - } - - // read and lseek are used to check the possibility to access the data - // not a nice solution, but it allows to avoid a crash in case it is an opened samba file - // generally, reading of one byte should not affect the performance - char nCh; - if ( 1 != read( SourceFileFD, &nCh, 1 ) - || -1 == lseek( SourceFileFD, 0, SEEK_SET ) ) - { - nRet = errno; - close( SourceFileFD ); - close( DestFileFD ); - return nRet; - } - size_t nWritten = 0; size_t nRemains = nSourceSize; - /* mmap file -- open dest file -- write -- fsync it at the end */ - void* pSourceFile = mmap( 0, nSourceSize, PROT_READ, MAP_SHARED, SourceFileFD, 0 ); - if ( pSourceFile != MAP_FAILED ) - { - nWritten = write( DestFileFD, pSourceFile, nSourceSize ); - nRemains -= nWritten; - munmap( (char*)pSourceFile, nSourceSize ); - } - if ( nRemains ) { /* mmap has problems, try the direct streaming */ - char pBuffer[32000]; + char pBuffer[0x8000]; size_t nRead = 0; nRemains = nSourceSize; - if ( -1 != lseek( SourceFileFD, 0, SEEK_SET ) - && -1 != lseek( DestFileFD, 0, SEEK_SET ) ) + do { - do - { - nRead = 0; - nWritten = 0; + nRead = 0; + nWritten = 0; - size_t nToRead = std::min( (size_t)32000, nRemains ); - nRead = read( SourceFileFD, pBuffer, nToRead ); - if ( (size_t)-1 != nRead ) - nWritten = write( DestFileFD, pBuffer, nRead ); + size_t nToRead = std::min( (size_t)0x8000, nRemains ); + nRead = read( SourceFileFD, pBuffer, nToRead ); + if ( (size_t)-1 != nRead ) + nWritten = write( DestFileFD, pBuffer, nRead ); - if ( (size_t)-1 != nWritten ) - nRemains -= nWritten; - } - while( nRemains && (size_t)-1 != nRead && nRead == nWritten ); + if ( (size_t)-1 != nWritten ) + nRemains -= nWritten; } + while( nRemains && (size_t)-1 != nRead && nRead == nWritten ); } if ( nRemains ) diff --git a/sal/prj/build.lst b/sal/prj/build.lst index c96c3977f725..06e3958443e9 100644 --- a/sal/prj/build.lst +++ b/sal/prj/build.lst @@ -20,3 +20,4 @@ sa sal\qa\OStringBuffer nmake - all sa_qa_OStringBuffer sa_cppunittester sa_util sa sal\qa\osl\mutex nmake - all sa_qa_osl_mutex sa_cppunittester sa_util NULL sa sal\qa\osl\pipe nmake - all sa_qa_osl_pipe sa_cppunittester sa_util NULL sa sal\qa\osl\profile nmake - all sa_qa_osl_profile sa_cppunittester sa_util NULL +sa sal\qa\rtl\math nmake - all sa_qa_rtl_math sa_cppunittester sa_util NULL diff --git a/sal/qa/OStringBuffer/makefile.mk b/sal/qa/OStringBuffer/makefile.mk index d46168dc4d0e..e0c1a81d66e3 100644 --- a/sal/qa/OStringBuffer/makefile.mk +++ b/sal/qa/OStringBuffer/makefile.mk @@ -33,8 +33,6 @@ PRJ=..$/.. PRJNAME=sal TARGET=qa_ostringbuffer -# this is removed at the moment because we need some enhancements -# TESTDIR=TRUE ENABLE_EXCEPTIONS=TRUE diff --git a/sal/qa/osl/process/makefile.mk b/sal/qa/osl/process/makefile.mk index 6bbee03b6aaf..e113ac86edee 100644 --- a/sal/qa/osl/process/makefile.mk +++ b/sal/qa/osl/process/makefile.mk @@ -28,8 +28,6 @@ PRJ=..$/..$/.. PRJNAME=sal TARGET=qa_osl_process -# this is removed at the moment because we need some enhancements -# TESTDIR=TRUE ENABLE_EXCEPTIONS=TRUE diff --git a/sal/qa/osl/profile/makefile.mk b/sal/qa/osl/profile/makefile.mk index a95db211c2a6..67ad60057c07 100644 --- a/sal/qa/osl/profile/makefile.mk +++ b/sal/qa/osl/profile/makefile.mk @@ -33,7 +33,6 @@ PRJ=..$/..$/.. PRJNAME=sal TARGET=qa_osl_profile -# TESTDIR=TRUE ENABLE_EXCEPTIONS=TRUE diff --git a/sal/qa/rtl/alloc/makefile.mk b/sal/qa/rtl/alloc/makefile.mk index 37ae3718b40d..db4f01eb439b 100755 --- a/sal/qa/rtl/alloc/makefile.mk +++ b/sal/qa/rtl/alloc/makefile.mk @@ -28,8 +28,6 @@ PRJ=..$/..$/.. PRJNAME=sal TARGET=qa_rtl_alloc -# this is removed at the moment because we need some enhancements -# TESTDIR=TRUE ENABLE_EXCEPTIONS=TRUE diff --git a/sal/qa/rtl/crc32/makefile.mk b/sal/qa/rtl/crc32/makefile.mk index 6bd3bd89d5a6..704c149d45cd 100755 --- a/sal/qa/rtl/crc32/makefile.mk +++ b/sal/qa/rtl/crc32/makefile.mk @@ -28,8 +28,6 @@ PRJ=..$/..$/.. PRJNAME=sal TARGET=qa_rtl_crc32 -# this is removed at the moment because we need some enhancements -# TESTDIR=TRUE ENABLE_EXCEPTIONS=TRUE diff --git a/sal/qa/rtl/digest/makefile.mk b/sal/qa/rtl/digest/makefile.mk index 415183b7e9a0..7798004ed854 100644 --- a/sal/qa/rtl/digest/makefile.mk +++ b/sal/qa/rtl/digest/makefile.mk @@ -29,8 +29,6 @@ INCPRE+= $(PRJ)$/qa$/inc PRJNAME=sal TARGET=rtl_digest -# this is removed at the moment because we need some enhancements -# TESTDIR=TRUE ENABLE_EXCEPTIONS=TRUE diff --git a/sal/qa/rtl/doublelock/makefile.mk b/sal/qa/rtl/doublelock/makefile.mk index b13ccf420c06..45259fd3cba0 100644 --- a/sal/qa/rtl/doublelock/makefile.mk +++ b/sal/qa/rtl/doublelock/makefile.mk @@ -28,8 +28,6 @@ PRJ=..$/..$/.. PRJNAME=sal TARGET=qa_rtl_doublelock -# this is removed at the moment because we need some enhancements -# TESTDIR=TRUE ENABLE_EXCEPTIONS=TRUE diff --git a/sal/qa/rtl/locale/makefile.mk b/sal/qa/rtl/locale/makefile.mk index 329769b5d3ec..d6c9c6b674a3 100644 --- a/sal/qa/rtl/locale/makefile.mk +++ b/sal/qa/rtl/locale/makefile.mk @@ -28,8 +28,6 @@ PRJ=..$/..$/.. PRJNAME=sal TARGET=qa_rtl_locale -# this is removed at the moment because we need some enhancements -# TESTDIR=TRUE ENABLE_EXCEPTIONS=TRUE diff --git a/sal/qa/rtl/math/export.exp b/sal/qa/rtl/math/export.exp deleted file mode 100644 index a13529da5876..000000000000 --- a/sal/qa/rtl/math/export.exp +++ /dev/null @@ -1 +0,0 @@ -registerAllTestFunction diff --git a/sal/qa/rtl/math/makefile.mk b/sal/qa/rtl/math/makefile.mk index 3b35e52ab1f4..59f2ecc495bb 100644 --- a/sal/qa/rtl/math/makefile.mk +++ b/sal/qa/rtl/math/makefile.mk @@ -1,7 +1,7 @@ #************************************************************************* # # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# +# # Copyright 2000, 2010 Oracle and/or its affiliates. # # OpenOffice.org - a multi-platform office productivity suite @@ -23,75 +23,33 @@ # <http://www.openoffice.org/license.html> # for a copy of the LGPLv3 License. # -#************************************************************************* -PRJ=..$/..$/.. -INCPRE+= $(PRJ)$/qa$/inc +#***********************************************************************/ -PRJNAME=sal -TARGET=rtl_math -# this is removed at the moment because we need some enhancements -# TESTDIR=TRUE +.IF "$(OOO_SUBSEQUENT_TESTS)" == "" +nothing .PHONY: +.ELSE -ENABLE_EXCEPTIONS=TRUE +PRJ = ../../.. +PRJNAME = sal +TARGET = qa_rtl_profile -# --- Settings ----------------------------------------------------- +ENABLE_EXCEPTIONS = TRUE -.INCLUDE : settings.mk - -CFLAGS+= $(LFS_CFLAGS) -CXXFLAGS+= $(LFS_CFLAGS) +.INCLUDE: settings.mk CFLAGSCXX += $(CPPUNIT_CFLAGS) -#----------------------------------- OStringBuffer ----------------------------------- - -SHL1OBJS= \ - $(SLO)$/test_rtl_math.obj - -SHL1TARGET= rtl_math -SHL1STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB) - -SHL1IMPLIB= i$(SHL1TARGET) -# SHL1DEF= $(MISC)$/$(SHL1TARGET).def - -DEF1NAME =$(SHL1TARGET) -# DEF1EXPORTFILE= export.exp -SHL1VERSIONMAP = $(PRJ)$/qa$/export.map - -# --- BEGIN -------------------------------------------------------- -SHL2OBJS= \ - $(SLO)$/rtl_math.obj -SHL2TARGET= rtl_math2 -SHL2STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB) - -SHL2IMPLIB= i$(SHL2TARGET) -DEF2NAME= $(SHL2TARGET) -SHL2VERSIONMAP = $(PRJ)$/qa$/export.map - - - -# # --- BEGIN -------------------------------------------------------- -# LLA: this is an old test, which seems not to work -# sal_setInt64() -# sal_getInt64() -# does not exist. -# -# SHL3OBJS= \ -# $(SLO)$/rtl_old_testint64.obj -# SHL3TARGET= rtl_old_testint64 -# SHL3STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB) -# -# SHL3IMPLIB= i$(SHL3TARGET) -# DEF3NAME= $(SHL3TARGET) -# SHL3VERSIONMAP = $(PRJ)$/qa$/export.map -# - -#------------------------------- All object files ------------------------------- -# do this here, so we get right dependencies -# SLOFILES=$(SHL1OBJS) +SHL1IMPLIB = i$(SHL1TARGET) +SHL1OBJS = $(SLO)/test-rtl-math.obj +SHL1RPATH = NONE +SHL1STDLIBS = $(CPPUNITLIB) $(SALLIB) +SHL1TARGET = test-rtl-math +SHL1VERSIONMAP = $(PRJ)/qa/export.map +DEF1NAME = $(SHL1TARGET) -# --- Targets ------------------------------------------------------ +SLOFILES = $(SHL1OBJS) -.INCLUDE : target.mk -.INCLUDE : _cppunit.mk +.INCLUDE: target.mk +.INCLUDE: _cppunit.mk +.END diff --git a/sal/qa/rtl/math/rtl_math.cxx b/sal/qa/rtl/math/rtl_math.cxx deleted file mode 100644 index 653106ce0e30..000000000000 --- a/sal/qa/rtl/math/rtl_math.cxx +++ /dev/null @@ -1,626 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_sal.hxx" -#ifdef WIN32 -// LLA: take a look into Microsofts math.h implementation, why this define is need -#define _USE_MATH_DEFINES -#endif - -#include <math.h> -#include <testshl/simpleheader.hxx> -#include <rtl/math.h> -#include <rtl/string.hxx> - -#include "valueequal.hxx" - -namespace rtl_math -{ - -class test : public CppUnit::TestFixture -{ -public: - // initialise your test code values here. - void setUp() - { - } - - void tearDown() - { - } - - - void equalCheck(double _nResult, double _nExpect) /* throws Exception */ - { - bool bEqualResult = is_double_equal(_nResult, _nExpect); - - rtl::OString sError = "rtl_math_round expected result is wrong should:("; - sError += rtl::OString::valueOf(_nExpect); - sError += ") but is:("; - sError += rtl::OString::valueOf(_nResult); - sError += ")"; - - CPPUNIT_ASSERT_MESSAGE(sError.getStr(), bEqualResult == true); - } - - // insert your test code here. - void round_000() - { - // this is demonstration code - // CPPUNIT_ASSERT_MESSAGE("a message", 1 == 1); - - double nValue = M_PI; - double nResult = 0.0; - - nResult = rtl_math_round(nValue, 0, rtl_math_RoundingMode_Corrected); - equalCheck(nResult, double(3.0)); - - nResult = rtl_math_round(nValue, 2, rtl_math_RoundingMode_Corrected); - equalCheck(nResult, double(3.14)); - - nResult = rtl_math_round(nValue, 3, rtl_math_RoundingMode_Corrected); - equalCheck(nResult, double(3.142)); - - nResult = rtl_math_round(nValue, 10, rtl_math_RoundingMode_Corrected); - equalCheck(nResult, double(3.1415926536)); - } - - // insert your test code here. - void round_001_positiv() - { - // this is demonstration code - // CPPUNIT_ASSERT_MESSAGE("a message", 1 == 1); - - double nResult = 0.0; - - nResult = rtl_math_round(0.1, 1, rtl_math_RoundingMode_Corrected); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.11, 1, rtl_math_RoundingMode_Corrected); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.13, 1, rtl_math_RoundingMode_Corrected); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.14, 1, rtl_math_RoundingMode_Corrected); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.1499999, 1, rtl_math_RoundingMode_Corrected); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.15, 1, rtl_math_RoundingMode_Corrected); - equalCheck(nResult, double(0.2)); - - nResult = rtl_math_round(0.151, 1, rtl_math_RoundingMode_Corrected); - equalCheck(nResult, double(0.2)); - - nResult = rtl_math_round(0.16, 1, rtl_math_RoundingMode_Corrected); - equalCheck(nResult, double(0.2)); - - nResult = rtl_math_round(0.199999999, 1, rtl_math_RoundingMode_Corrected); - equalCheck(nResult, double(0.2)); - } - - void round_001_negativ() - { - // this is demonstration code - // CPPUNIT_ASSERT_MESSAGE("a message", 1 == 1); - - double nResult = 0.0; - - nResult = rtl_math_round(-0.1, 1, rtl_math_RoundingMode_Corrected); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.11, 1, rtl_math_RoundingMode_Corrected); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.13, 1, rtl_math_RoundingMode_Corrected); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.14, 1, rtl_math_RoundingMode_Corrected); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.1499999, 1, rtl_math_RoundingMode_Corrected); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.15, 1, rtl_math_RoundingMode_Corrected); - equalCheck(nResult, double(-0.2)); - - nResult = rtl_math_round(-0.151, 1, rtl_math_RoundingMode_Corrected); - equalCheck(nResult, double(-0.2)); - - nResult = rtl_math_round(-0.16, 1, rtl_math_RoundingMode_Corrected); - equalCheck(nResult, double(-0.2)); - - nResult = rtl_math_round(-0.19999999999, 1, rtl_math_RoundingMode_Corrected); - equalCheck(nResult, double(-0.2)); - } -// ----------------------------------------------------------------------------- - void round_002_positiv() - { - // this is demonstration code - // CPPUNIT_ASSERT_MESSAGE("a message", 1 == 1); - - double nResult = 0.0; - - nResult = rtl_math_round(0.1, 1, rtl_math_RoundingMode_Down); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.11, 1, rtl_math_RoundingMode_Down); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.13, 1, rtl_math_RoundingMode_Down); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.14, 1, rtl_math_RoundingMode_Down); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.1499999, 1, rtl_math_RoundingMode_Down); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.15, 1, rtl_math_RoundingMode_Down); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.151, 1, rtl_math_RoundingMode_Down); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.16, 1, rtl_math_RoundingMode_Down); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.199999999, 1, rtl_math_RoundingMode_Down); - equalCheck(nResult, double(0.1)); - } - - void round_002_negativ() - { - // this is demonstration code - // CPPUNIT_ASSERT_MESSAGE("a message", 1 == 1); - - double nResult = 0.0; - - nResult = rtl_math_round(-0.1, 1, rtl_math_RoundingMode_Down); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.11, 1, rtl_math_RoundingMode_Down); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.13, 1, rtl_math_RoundingMode_Down); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.14, 1, rtl_math_RoundingMode_Down); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.1499999, 1, rtl_math_RoundingMode_Down); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.15, 1, rtl_math_RoundingMode_Down); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.151, 1, rtl_math_RoundingMode_Down); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.16, 1, rtl_math_RoundingMode_Down); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.19999999999, 1, rtl_math_RoundingMode_Down); - equalCheck(nResult, double(-0.1)); - } -// ----------------------------------------------------------------------------- - void round_003_positiv() - { - // this is demonstration code - // CPPUNIT_ASSERT_MESSAGE("a message", 1 == 1); - - double nResult = 0.0; - - nResult = rtl_math_round(0.1, 1, rtl_math_RoundingMode_Up); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.11, 1, rtl_math_RoundingMode_Up); - equalCheck(nResult, double(0.2)); - - nResult = rtl_math_round(0.13, 1, rtl_math_RoundingMode_Up); - equalCheck(nResult, double(0.2)); - - nResult = rtl_math_round(0.14, 1, rtl_math_RoundingMode_Up); - equalCheck(nResult, double(0.2)); - - nResult = rtl_math_round(0.1499999, 1, rtl_math_RoundingMode_Up); - equalCheck(nResult, double(0.2)); - - nResult = rtl_math_round(0.15, 1, rtl_math_RoundingMode_Up); - equalCheck(nResult, double(0.2)); - - nResult = rtl_math_round(0.151, 1, rtl_math_RoundingMode_Up); - equalCheck(nResult, double(0.2)); - - nResult = rtl_math_round(0.16, 1, rtl_math_RoundingMode_Up); - equalCheck(nResult, double(0.2)); - - nResult = rtl_math_round(0.199999999, 1, rtl_math_RoundingMode_Up); - equalCheck(nResult, double(0.2)); - } - - void round_003_negativ() - { - // this is demonstration code - // CPPUNIT_ASSERT_MESSAGE("a message", 1 == 1); - - double nResult = 0.0; - - nResult = rtl_math_round(-0.1, 1, rtl_math_RoundingMode_Up); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.11, 1, rtl_math_RoundingMode_Up); - equalCheck(nResult, double(-0.2)); - - nResult = rtl_math_round(-0.13, 1, rtl_math_RoundingMode_Up); - equalCheck(nResult, double(-0.2)); - - nResult = rtl_math_round(-0.14, 1, rtl_math_RoundingMode_Up); - equalCheck(nResult, double(-0.2)); - - nResult = rtl_math_round(-0.1499999, 1, rtl_math_RoundingMode_Up); - equalCheck(nResult, double(-0.2)); - - nResult = rtl_math_round(-0.15, 1, rtl_math_RoundingMode_Up); - equalCheck(nResult, double(-0.2)); - - nResult = rtl_math_round(-0.151, 1, rtl_math_RoundingMode_Up); - equalCheck(nResult, double(-0.2)); - - nResult = rtl_math_round(-0.16, 1, rtl_math_RoundingMode_Up); - equalCheck(nResult, double(-0.2)); - - nResult = rtl_math_round(-0.19999999999, 1, rtl_math_RoundingMode_Up); - equalCheck(nResult, double(-0.2)); - } -// ----------------------------------------------------------------------------- - void round_004_positiv() - { - // this is demonstration code - // CPPUNIT_ASSERT_MESSAGE("a message", 1 == 1); - - double nResult = 0.0; - - nResult = rtl_math_round(0.1, 1, rtl_math_RoundingMode_Floor); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.11, 1, rtl_math_RoundingMode_Floor); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.13, 1, rtl_math_RoundingMode_Floor); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.14, 1, rtl_math_RoundingMode_Floor); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.1499999, 1, rtl_math_RoundingMode_Floor); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.15, 1, rtl_math_RoundingMode_Floor); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.151, 1, rtl_math_RoundingMode_Floor); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.16, 1, rtl_math_RoundingMode_Floor); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.199999999, 1, rtl_math_RoundingMode_Floor); - equalCheck(nResult, double(0.1)); - } - - void round_004_negativ() - { - // this is demonstration code - // CPPUNIT_ASSERT_MESSAGE("a message", 1 == 1); - - double nResult = 0.0; - - nResult = rtl_math_round(-0.1, 1, rtl_math_RoundingMode_Floor); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.11, 1, rtl_math_RoundingMode_Floor); - equalCheck(nResult, double(-0.2)); - - nResult = rtl_math_round(-0.13, 1, rtl_math_RoundingMode_Floor); - equalCheck(nResult, double(-0.2)); - - nResult = rtl_math_round(-0.14, 1, rtl_math_RoundingMode_Floor); - equalCheck(nResult, double(-0.2)); - - nResult = rtl_math_round(-0.1499999, 1, rtl_math_RoundingMode_Floor); - equalCheck(nResult, double(-0.2)); - - nResult = rtl_math_round(-0.15, 1, rtl_math_RoundingMode_Floor); - equalCheck(nResult, double(-0.2)); - - nResult = rtl_math_round(-0.151, 1, rtl_math_RoundingMode_Floor); - equalCheck(nResult, double(-0.2)); - - nResult = rtl_math_round(-0.16, 1, rtl_math_RoundingMode_Floor); - equalCheck(nResult, double(-0.2)); - - nResult = rtl_math_round(-0.19999999999, 1, rtl_math_RoundingMode_Floor); - equalCheck(nResult, double(-0.2)); - } -// ----------------------------------------------------------------------------- - void round_005_positiv() - { - // this is demonstration code - // CPPUNIT_ASSERT_MESSAGE("a message", 1 == 1); - - double nResult = 0.0; - - nResult = rtl_math_round(0.1, 1, rtl_math_RoundingMode_Ceiling); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.11, 1, rtl_math_RoundingMode_Ceiling); - equalCheck(nResult, double(0.2)); - - nResult = rtl_math_round(0.13, 1, rtl_math_RoundingMode_Ceiling); - equalCheck(nResult, double(0.2)); - - nResult = rtl_math_round(0.14, 1, rtl_math_RoundingMode_Ceiling); - equalCheck(nResult, double(0.2)); - - nResult = rtl_math_round(0.1499999, 1, rtl_math_RoundingMode_Ceiling); - equalCheck(nResult, double(0.2)); - - nResult = rtl_math_round(0.15, 1, rtl_math_RoundingMode_Ceiling); - equalCheck(nResult, double(0.2)); - - nResult = rtl_math_round(0.151, 1, rtl_math_RoundingMode_Ceiling); - equalCheck(nResult, double(0.2)); - - nResult = rtl_math_round(0.16, 1, rtl_math_RoundingMode_Ceiling); - equalCheck(nResult, double(0.2)); - - nResult = rtl_math_round(0.199999999, 1, rtl_math_RoundingMode_Ceiling); - equalCheck(nResult, double(0.2)); - } - - void round_005_negativ() - { - // this is demonstration code - // CPPUNIT_ASSERT_MESSAGE("a message", 1 == 1); - - double nResult = 0.0; - - nResult = rtl_math_round(-0.1, 1, rtl_math_RoundingMode_Ceiling); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.11, 1, rtl_math_RoundingMode_Ceiling); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.13, 1, rtl_math_RoundingMode_Ceiling); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.14, 1, rtl_math_RoundingMode_Ceiling); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.1499999, 1, rtl_math_RoundingMode_Ceiling); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.15, 1, rtl_math_RoundingMode_Ceiling); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.151, 1, rtl_math_RoundingMode_Ceiling); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.16, 1, rtl_math_RoundingMode_Ceiling); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.19999999999, 1, rtl_math_RoundingMode_Ceiling); - equalCheck(nResult, double(-0.1)); - } -// ----------------------------------------------------------------------------- - void round_006_positiv() - { - // this is demonstration code - // CPPUNIT_ASSERT_MESSAGE("a message", 1 == 1); - - double nResult = 0.0; - - nResult = rtl_math_round(0.1, 1, rtl_math_RoundingMode_HalfDown); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.11, 1, rtl_math_RoundingMode_HalfDown); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.13, 1, rtl_math_RoundingMode_HalfDown); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.14, 1, rtl_math_RoundingMode_HalfDown); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.1499999, 1, rtl_math_RoundingMode_HalfDown); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.15, 1, rtl_math_RoundingMode_HalfDown); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.151, 1, rtl_math_RoundingMode_HalfDown); - equalCheck(nResult, double(0.2)); - - nResult = rtl_math_round(0.16, 1, rtl_math_RoundingMode_HalfDown); - equalCheck(nResult, double(0.2)); - - nResult = rtl_math_round(0.199999999, 1, rtl_math_RoundingMode_HalfDown); - equalCheck(nResult, double(0.2)); - } - - void round_006_negativ() - { - // this is demonstration code - // CPPUNIT_ASSERT_MESSAGE("a message", 1 == 1); - - double nResult = 0.0; - - nResult = rtl_math_round(-0.1, 1, rtl_math_RoundingMode_HalfDown); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.11, 1, rtl_math_RoundingMode_HalfDown); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.13, 1, rtl_math_RoundingMode_HalfDown); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.14, 1, rtl_math_RoundingMode_HalfDown); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.1499999, 1, rtl_math_RoundingMode_HalfDown); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.15, 1, rtl_math_RoundingMode_HalfDown); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.151, 1, rtl_math_RoundingMode_HalfDown); - equalCheck(nResult, double(-0.2)); - - nResult = rtl_math_round(-0.16, 1, rtl_math_RoundingMode_HalfDown); - equalCheck(nResult, double(-0.2)); - - nResult = rtl_math_round(-0.19999999999, 1, rtl_math_RoundingMode_HalfDown); - equalCheck(nResult, double(-0.2)); - } -// ----------------------------------------------------------------------------- - void round_007_positiv() - { - // this is demonstration code - // CPPUNIT_ASSERT_MESSAGE("a message", 1 == 1); - - double nResult = 0.0; - - nResult = rtl_math_round(0.1, 1, rtl_math_RoundingMode_HalfUp); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.11, 1, rtl_math_RoundingMode_HalfUp); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.13, 1, rtl_math_RoundingMode_HalfUp); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.14, 1, rtl_math_RoundingMode_HalfUp); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.1499999, 1, rtl_math_RoundingMode_HalfUp); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.15, 1, rtl_math_RoundingMode_HalfUp); - equalCheck(nResult, double(0.2)); - - nResult = rtl_math_round(0.151, 1, rtl_math_RoundingMode_HalfUp); - equalCheck(nResult, double(0.2)); - - nResult = rtl_math_round(0.16, 1, rtl_math_RoundingMode_HalfUp); - equalCheck(nResult, double(0.2)); - - nResult = rtl_math_round(0.199999999, 1, rtl_math_RoundingMode_HalfUp); - equalCheck(nResult, double(0.2)); - } - - void round_007_negativ() - { - // this is demonstration code - // CPPUNIT_ASSERT_MESSAGE("a message", 1 == 1); - - double nResult = 0.0; - - nResult = rtl_math_round(-0.1, 1, rtl_math_RoundingMode_HalfUp); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.11, 1, rtl_math_RoundingMode_HalfUp); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.13, 1, rtl_math_RoundingMode_HalfUp); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.14, 1, rtl_math_RoundingMode_HalfUp); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.1499999, 1, rtl_math_RoundingMode_HalfUp); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.15, 1, rtl_math_RoundingMode_HalfUp); - equalCheck(nResult, double(-0.2)); - - nResult = rtl_math_round(-0.151, 1, rtl_math_RoundingMode_HalfUp); - equalCheck(nResult, double(-0.2)); - - nResult = rtl_math_round(-0.16, 1, rtl_math_RoundingMode_HalfUp); - equalCheck(nResult, double(-0.2)); - - nResult = rtl_math_round(-0.19999999999, 1, rtl_math_RoundingMode_HalfUp); - equalCheck(nResult, double(-0.2)); - } - - // Change the following lines only, if you add, remove or rename - // member functions of the current class, - // because these macros are need by auto register mechanism. - - CPPUNIT_TEST_SUITE(test); - CPPUNIT_TEST(round_000); - - CPPUNIT_TEST(round_001_positiv); - CPPUNIT_TEST(round_001_negativ); - - CPPUNIT_TEST(round_002_positiv); - CPPUNIT_TEST(round_002_negativ); - - CPPUNIT_TEST(round_003_positiv); - CPPUNIT_TEST(round_003_negativ); - - CPPUNIT_TEST(round_004_positiv); - CPPUNIT_TEST(round_004_negativ); - - CPPUNIT_TEST(round_005_positiv); - CPPUNIT_TEST(round_005_negativ); - - CPPUNIT_TEST(round_006_positiv); - CPPUNIT_TEST(round_006_negativ); - - CPPUNIT_TEST(round_007_positiv); - CPPUNIT_TEST(round_007_negativ); - - CPPUNIT_TEST_SUITE_END(); -}; // class test - -// ----------------------------------------------------------------------------- -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_math::test, "rtl_math"); -} // namespace rtl_math - - -// ----------------------------------------------------------------------------- - -// this macro creates an empty function, which will called by the RegisterAllFunctions() -// to let the user the possibility to also register some functions by hand. -NOADDITIONAL; - diff --git a/sal/qa/rtl/math/rtl_old_testint64.cxx b/sal/qa/rtl/math/rtl_old_testint64.cxx deleted file mode 100644 index e1f30ac03be6..000000000000 --- a/sal/qa/rtl/math/rtl_old_testint64.cxx +++ /dev/null @@ -1,122 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_sal.hxx" - -// LLA: -// this file is converted to use with testshl2 -// original was placed in sal/test/textenc.cxx - -// fndef _OSL_DIAGNOSE_H_ -// nclude <osl/diagnose.h> -// #endif - -#include <sal/types.h> - -#define TEST_ENSURE(c, m) CPPUNIT_ASSERT_MESSAGE((m), (c)) - -// #if OSL_DEBUG_LEVEL > 0 -// #define TEST_ENSURE(c, m) OSL_ENSURE(c, m) -// #else -// #define TEST_ENSURE(c, m) OSL_VERIFY(c) -// #endif - -#include <testshl/simpleheader.hxx> - -// ----------------------------------------------------------------------------- -namespace rtl_math -{ - class int64 : public CppUnit::TestFixture - { - public: - void test_int64(); - - CPPUNIT_TEST_SUITE( int64 ); - CPPUNIT_TEST( test_int64 ); - CPPUNIT_TEST_SUITE_END( ); - }; - -void int64::test_int64() -{ -#ifndef SAL_INT64_IS_STRUCT -#ifdef UNX - sal_Int64 i1 = -3223372036854775807LL; - sal_uInt64 u1 = 5223372036854775807ULL; -#else - sal_Int64 i1 = -3223372036854775807; - sal_uInt64 u1 = 5223372036854775807; -#endif - sal_Int64 i2 = 0; - sal_uInt64 u2 = 0; -#else - sal_Int64 i1; - sal_setInt64(&i1, 3965190145L, -750499787L); - - sal_Int64 i2 = { 0, 0 }; - - sal_uInt64 u1; - sal_setUInt64(&u1, 1651507199UL, 1216161073UL); - - sal_uInt64 u2 = {0, 0 }; - -#endif - sal_uInt32 low = 0; - sal_Int32 high = 0; - - sal_getInt64(i1, &low, &high); - sal_setInt64(&i2, low, high); - - sal_uInt32 ulow = 0; - sal_uInt32 uhigh = 0; - - sal_getUInt64(u1, &ulow, &uhigh); - sal_setUInt64(&u2, ulow, uhigh); - -#ifndef SAL_INT64_IS_STRUCT - TEST_ENSURE( i1 == i2, "test_int64 error 1"); - - TEST_ENSURE( u1 == u2, "test_int64 error 2"); -#else - TEST_ENSURE( (i1.Part1 == i2.Part1) && (i1.Part2 == i2.Part2), - "test_int64 error 1"); - - TEST_ENSURE( (u1.Part1 == u2.Part1) && (u1.Part2 == u2.Part2), - "test_int64 error 2"); -#endif - return; -} - -} // namespace rtl_math - -// ----------------------------------------------------------------------------- -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( rtl_math::int64, "rtl_math" ); - -// ----------------------------------------------------------------------------- -NOADDITIONAL; - - diff --git a/sal/qa/rtl/math/test-rtl-math.cxx b/sal/qa/rtl/math/test-rtl-math.cxx new file mode 100644 index 000000000000..8e9875444280 --- /dev/null +++ b/sal/qa/rtl/math/test-rtl-math.cxx @@ -0,0 +1,76 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +#include "precompiled_sal.hxx" +#include "sal/config.h" + +#include "cppunit/TestAssert.h" +#include "cppunit/TestFixture.h" +#include "cppunit/extensions/HelperMacros.h" +#include "cppunit/plugin/TestPlugIn.h" +#include "rtl/math.hxx" +#include "rtl/ustring.h" +#include "rtl/ustring.hxx" +#include "sal/types.h" + +namespace { + +class Test: public CppUnit::TestFixture { +public: + void test_stringToDouble_good() { + rtl_math_ConversionStatus status; + sal_Int32 end; + double res = rtl::math::stringToDouble( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" +1.E01foo")), + sal_Unicode('.'), sal_Unicode(','), &status, &end); + CPPUNIT_ASSERT_EQUAL(rtl_math_ConversionStatus_Ok, status); + CPPUNIT_ASSERT_EQUAL(sal_Int32(RTL_CONSTASCII_LENGTH(" +1.E01")), end); + CPPUNIT_ASSERT_EQUAL(10.0, res); + } + + void test_stringToDouble_bad() { + rtl_math_ConversionStatus status; + sal_Int32 end; + double res = rtl::math::stringToDouble( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" +Efoo")), + sal_Unicode('.'), sal_Unicode(','), &status, &end); + CPPUNIT_ASSERT_EQUAL(rtl_math_ConversionStatus_Ok, status); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), end); + CPPUNIT_ASSERT_EQUAL(0.0, res); + } + + CPPUNIT_TEST_SUITE(Test); + CPPUNIT_TEST(test_stringToDouble_good); + CPPUNIT_TEST(test_stringToDouble_bad); + CPPUNIT_TEST_SUITE_END(); +}; + +CPPUNIT_TEST_SUITE_REGISTRATION(Test); + +} + +CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sal/qa/rtl/math/test_rtl_math.cxx b/sal/qa/rtl/math/test_rtl_math.cxx deleted file mode 100644 index 887e3ddd1214..000000000000 --- a/sal/qa/rtl/math/test_rtl_math.cxx +++ /dev/null @@ -1,674 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_sal.hxx" - -#include "rtl/math.h" -#include "rtl/math.hxx" -#include "rtl/strbuf.hxx" -#include "rtl/string.h" -#include "rtl/string.hxx" -#include "rtl/textenc.h" -// #include "rtl/tres.h" -#include <testshl/tresstatewrapper.hxx> -#include "rtl/ustring.hxx" -#include "sal/types.h" - -#include <stdlib.h> - -namespace { - -struct FloatTraits -{ - typedef float Number; - - static inline char const * getPrefix() { return "float"; } -}; - -struct DoubleTraits -{ - typedef double Number; - - static inline char const * getPrefix() { return "double"; } -}; - -struct StringTraits -{ - typedef rtl::OString String; - - static inline char const * getPrefix() { return "OString"; } - - static inline rtl::OString createFromAscii(char const * pString) - { return rtl::OString(pString); } - - static inline void appendBuffer(rtl::OStringBuffer & rBuffer, - rtl::OString const & rString) - { rBuffer.append(rString); } - - static inline rtl::OString doubleToString(double fValue, - rtl_math_StringFormat eFormat, - sal_Int32 nDecPlaces, - sal_Char cDecSeparator, - bool bEraseTrailingDecZeros) - { - return rtl::math::doubleToString(fValue, eFormat, nDecPlaces, - cDecSeparator, bEraseTrailingDecZeros); - } -}; - -struct UStringTraits -{ - typedef rtl::OUString String; - - static inline char const * getPrefix() { return "OUString"; } - - static inline rtl::OUString createFromAscii(char const * pString) - { return rtl::OUString::createFromAscii(pString); } - - static inline void appendBuffer(rtl::OStringBuffer & rBuffer, - rtl::OUString const & rString) - { rBuffer.append(rtl::OUStringToOString(rString, RTL_TEXTENCODING_UTF8)); } - - static inline rtl::OUString doubleToString(double fValue, - rtl_math_StringFormat eFormat, - sal_Int32 nDecPlaces, - sal_Unicode cDecSeparator, - bool bEraseTrailingDecZeros) - { - return rtl::math::doubleToUString(fValue, eFormat, nDecPlaces, - cDecSeparator, - bEraseTrailingDecZeros); - } -}; - -struct TestNumberToString -{ - double fValue; - rtl_math_StringFormat eFormat; - sal_Int32 nDecPlaces; - char cDecSeparator; - bool bEraseTrailingDecZeros; - char const * pResult; -}; - -template< typename StringT, typename NumberT > -bool testNumberToString(hTestResult pTestResult, - TestNumberToString const & rTest) -{ - typename NumberT::Number fValue = static_cast< typename NumberT::Number >(rTest.fValue); - if (fValue != rTest.fValue) - return true; - - // LLA: t_print("size: %d ", sizeof(fValue)); - typename StringT::String aResult1; - - aResult1 = StringT::doubleToString(fValue, rTest.eFormat, rTest.nDecPlaces, - rTest.cDecSeparator, - rTest.bEraseTrailingDecZeros); - - typename StringT::String aResult2(StringT::createFromAscii(rTest.pResult)); - - // LLA: rtl::OStringBuffer aBuf; - // LLA: StringT::appendBuffer(aBuf, aResult1); - // LLA: t_print("aResult1: %s ", aBuf.getStr()); - // LLA: - // LLA: rtl::OStringBuffer aBuf2; - // LLA: StringT::appendBuffer(aBuf2, aResult2); - // LLA: t_print("aResult2: %s\n", aBuf2.getStr()); - - bool bSuccess = aResult1 == aResult2; - - rtl::OStringBuffer aBuffer; - aBuffer.append(StringT::getPrefix()); - aBuffer.append(RTL_CONSTASCII_STRINGPARAM("/")); - aBuffer.append(NumberT::getPrefix()); - aBuffer.append(RTL_CONSTASCII_STRINGPARAM(" doubleToString(")); - aBuffer.append(fValue); - aBuffer.append(RTL_CONSTASCII_STRINGPARAM(", ")); - aBuffer.append(static_cast< sal_Int32 >(rTest.eFormat)); - aBuffer.append(RTL_CONSTASCII_STRINGPARAM(", ")); - aBuffer.append(rTest.nDecPlaces); - aBuffer.append(RTL_CONSTASCII_STRINGPARAM(", ")); - aBuffer.append(rTest.cDecSeparator); - aBuffer.append(RTL_CONSTASCII_STRINGPARAM(", ")); - aBuffer.append(static_cast< sal_Int32 >(rTest.bEraseTrailingDecZeros)); - aBuffer.append(RTL_CONSTASCII_STRINGPARAM("): ")); - StringT::appendBuffer(aBuffer, aResult1); - if (!bSuccess) - { - aBuffer.append(RTL_CONSTASCII_STRINGPARAM(" != ")); - StringT::appendBuffer(aBuffer, aResult2); - } - // call to the real test checker - // pTestResult->pFuncs->state_(pTestResult, bSuccess, "test_rtl_math", - // aBuffer.getStr(), false); - c_rtl_tres_state(pTestResult, bSuccess, aBuffer.getStr(), "testNumberToString"); - return bSuccess; -} - -template< typename StringT, typename NumberT > -bool testNumberToString(hTestResult pTestResult, - TestNumberToString const * pTests, size_t nCount) -{ - bool bSuccess = true; - for (size_t i = 0; i < nCount; ++i) - bSuccess &= testNumberToString< StringT, NumberT >(pTestResult, - pTests[i]); - return bSuccess; -} - -struct TestStringToNumberToString -{ - char const * pValue; - rtl_math_StringFormat eFormat; - sal_Int32 nDecPlaces; - char cDecSeparator; - bool bEraseTrailingDecZeros; - char const * pResult; -}; - -template< typename StringT > -bool testStringToNumberToString(hTestResult pTestResult, - TestStringToNumberToString const & rTest) -{ - double d = rtl::math::stringToDouble(StringT::createFromAscii(rTest.pValue), - rTest.cDecSeparator, 0, 0, 0); - typename StringT::String aResult1( - StringT::doubleToString(d, rTest.eFormat, rTest.nDecPlaces, - rTest.cDecSeparator, - rTest.bEraseTrailingDecZeros)); - typename StringT::String aResult2(StringT::createFromAscii(rTest.pResult)); - bool bSuccess = aResult1 == aResult2; - rtl::OStringBuffer aBuffer; - aBuffer.append(StringT::getPrefix()); - aBuffer.append(RTL_CONSTASCII_STRINGPARAM( - " doubleToString(stringToDouble(")); - aBuffer.append(rTest.pValue); - aBuffer.append(RTL_CONSTASCII_STRINGPARAM(", ")); - aBuffer.append(rTest.cDecSeparator); - aBuffer.append(RTL_CONSTASCII_STRINGPARAM("), ")); - aBuffer.append(static_cast< sal_Int32 >(rTest.eFormat)); - aBuffer.append(RTL_CONSTASCII_STRINGPARAM(", ")); - aBuffer.append(rTest.nDecPlaces); - aBuffer.append(RTL_CONSTASCII_STRINGPARAM(", ")); - aBuffer.append(rTest.cDecSeparator); - aBuffer.append(RTL_CONSTASCII_STRINGPARAM(", ")); - aBuffer.append(static_cast< sal_Int32 >(rTest.bEraseTrailingDecZeros)); - aBuffer.append(RTL_CONSTASCII_STRINGPARAM("): ")); - StringT::appendBuffer(aBuffer, aResult1); - if (!bSuccess) - { - aBuffer.append(RTL_CONSTASCII_STRINGPARAM(" != ")); - StringT::appendBuffer(aBuffer, aResult2); - } - // call to the real test checker - // pTestResult->pFuncs->state_(pTestResult, bSuccess, "test_rtl_math", - // aBuffer.getStr(), false); - c_rtl_tres_state(pTestResult, bSuccess, aBuffer.getStr(), "testStringToNumberToString"); - - return bSuccess; -} - -template< typename StringT > -bool testStringToNumberToString(hTestResult pTestResult, - TestStringToNumberToString const * pTests, - size_t nCount) -{ - bool bSuccess = true; - for (size_t i = 0; i < nCount; ++i) - bSuccess &= testStringToNumberToString< StringT >(pTestResult, - pTests[i]); - return bSuccess; -} - -} - -extern "C" sal_Bool SAL_CALL test_rtl_math(hTestResult pTestResult) -{ - bool bReturn = true; - - { - static TestNumberToString const aTest[] - = { // 1, 1+2^-1, ..., 1+2^-52 - // Too few decimal digits are printed, so that various different - // double values lead to the same output: - { 1, rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "1" }, - { 1.5, rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "1.5" }, - { 1.25, rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "1.25" }, - { 1.125, rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "1.125" }, - { 1.0625, rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "1.0625" }, - { 1.03125, rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "1.03125" }, - { 1.015625, rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "1.015625" }, - { 1.0078125, rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "1.0078125" }, - { 1.00390625, rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "1.00390625" }, - { 1.001953125, rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "1.001953125" }, - { 1.0009765625, rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "1.0009765625" }, - { 1.00048828125, rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "1.00048828125" }, - { 1.000244140625, rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "1.000244140625" }, - { 1.0001220703125, rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "1.0001220703125" }, - { 1.00006103515625, rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "1.00006103515625" }, - { 1.000030517578125, rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "1.00003051757813" }, - { 1.0000152587890625, rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "1.00001525878906" }, - { 1.00000762939453125, rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "1.00000762939453" }, - { 1.000003814697265625, rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "1.00000381469727" }, - { 1.0000019073486328125, rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "1.00000190734863" }, - { 1.00000095367431640625, rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "1.00000095367432" }, - { 1.000000476837158203125, rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "1.00000047683716" }, - { 1.0000002384185791015625, rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "1.00000023841858" }, - { 1.00000011920928955078125, rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "1.00000011920929" }, - { 1.000000059604644775390625, rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "1.00000005960464" }, - { 1.0000000298023223876953125, rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "1.00000002980232" }, - { 1.00000001490116119384765625, rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "1.00000001490116" }, - { 1.000000007450580596923828125, - rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, - '.', true, "1.00000000745058" }, - { 1.0000000037252902984619140625, - rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, - '.', true, "1.00000000372529" }, - { 1.00000000186264514923095703125, - rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, - '.', true, "1.00000000186265" }, - { 1.000000000931322574615478515625, - rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, - '.', true, "1.00000000093132" }, - { 1.0000000004656612873077392578125, - rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, - '.', true, "1.00000000046566" }, - { 1.00000000023283064365386962890625, - rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, - '.', true, "1.00000000023283" }, - { 1.000000000116415321826934814453125, - rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, - '.', true, "1.00000000011642" }, - { 1.0000000000582076609134674072265625, - rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, - '.', true, "1.00000000005821" }, - { 1.00000000002910383045673370361328125, - rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, - '.', true, "1.0000000000291" }, - { 1.000000000014551915228366851806640625, - rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, - '.', true, "1.00000000001455" }, - { 1.0000000000072759576141834259033203125, - rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, - '.', true, "1.00000000000728" }, - { 1.00000000000363797880709171295166015625, - rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, - '.', true, "1.00000000000364" }, - { 1.000000000001818989403545856475830078125, - rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, - '.', true, "1.00000000000182" }, - { 1.0000000000009094947017729282379150390625, - rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, - '.', true, "1.00000000000091" }, - { 1.00000000000045474735088646411895751953125, - rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, - '.', true, "1.00000000000045" }, - { 1.000000000000227373675443232059478759765625, - rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, - '.', true, "1.00000000000023" }, - { 1.0000000000001136868377216160297393798828125, - rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, - '.', true, "1.00000000000011" }, - { 1.00000000000005684341886080801486968994140625, - rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, - '.', true, "1.00000000000006" }, - { 1.000000000000028421709430404007434844970703125, - rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, - '.', true, "1.00000000000003" }, - { 1.0000000000000142108547152020037174224853515625, - rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, - '.', true, "1.00000000000001" }, - { 1.00000000000000710542735760100185871124267578125, - rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, - '.', true, "1.00000000000001" }, - { 1.000000000000003552713678800500929355621337890625, - rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, - '.', true, "1" }, - { 1.0000000000000017763568394002504646778106689453125, - rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, - '.', true, "1" }, - { 1.00000000000000088817841970012523233890533447265625, - rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, - '.', true, "1" }, - { 1.000000000000000444089209850062616169452667236328125, - rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, - '.', true, "1" }, - { 1.0000000000000002220446049250313080847263336181640625, - rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, - '.', true, "1" }, - - // 1, 1+2^-1, ..., 1+2^-52 - // Too few decimal digits are printed, so that various different - // double values lead to the same output: - { 1, rtl_math_StringFormat_F, 53, '.', false, - "1.00000000000000000000000000000000000000000000000000000" }, - { 1.5, rtl_math_StringFormat_F, 53, '.', false, - "1.50000000000000000000000000000000000000000000000000000" }, - { 1.25, rtl_math_StringFormat_F, 53, '.', false, - "1.25000000000000000000000000000000000000000000000000000" }, - { 1.125, rtl_math_StringFormat_F, 53, '.', false, - "1.12500000000000000000000000000000000000000000000000000" }, - { 1.0625, rtl_math_StringFormat_F, 53, '.', false, - "1.06250000000000000000000000000000000000000000000000000" }, - { 1.03125, rtl_math_StringFormat_F, 53, '.', false, - "1.03125000000000000000000000000000000000000000000000000" }, - { 1.015625, rtl_math_StringFormat_F, 53, '.', false, - "1.01562500000000000000000000000000000000000000000000000" }, - { 1.0078125, rtl_math_StringFormat_F, 53, '.', false, - "1.00781250000000000000000000000000000000000000000000000" }, - { 1.00390625, rtl_math_StringFormat_F, 53, '.', false, - "1.00390625000000000000000000000000000000000000000000000" }, - { 1.001953125, rtl_math_StringFormat_F, 53, '.', false, - "1.00195312500000000000000000000000000000000000000000000" }, - { 1.0009765625, rtl_math_StringFormat_F, 53, '.', false, - "1.00097656250000000000000000000000000000000000000000000" }, - { 1.00048828125, rtl_math_StringFormat_F, 53, '.', false, - "1.00048828125000000000000000000000000000000000000000000" }, - { 1.000244140625, rtl_math_StringFormat_F, 53, '.', false, - "1.00024414062500000000000000000000000000000000000000000" }, - { 1.0001220703125, rtl_math_StringFormat_F, 53, '.', false, - "1.00012207031250000000000000000000000000000000000000000" }, - { 1.00006103515625, rtl_math_StringFormat_F, 53, '.', false, - "1.00006103515625000000000000000000000000000000000000000" }, - { 1.000030517578125, rtl_math_StringFormat_F, 53, '.', false, - "1.00003051757813000000000000000000000000000000000000000" }, - { 1.0000152587890625, rtl_math_StringFormat_F, 53, '.', false, - "1.00001525878906000000000000000000000000000000000000000" }, - { 1.00000762939453125, rtl_math_StringFormat_F, 53, '.', false, - "1.00000762939453000000000000000000000000000000000000000" }, - { 1.000003814697265625, rtl_math_StringFormat_F, 53, '.', false, - "1.00000381469727000000000000000000000000000000000000000" }, - { 1.0000019073486328125, rtl_math_StringFormat_F, 53, '.', - false, - "1.00000190734863000000000000000000000000000000000000000" }, - { 1.00000095367431640625, rtl_math_StringFormat_F, 53, '.', - false, - "1.00000095367432000000000000000000000000000000000000000" }, - { 1.000000476837158203125, rtl_math_StringFormat_F, 53, '.', - false, - "1.00000047683716000000000000000000000000000000000000000" }, - { 1.0000002384185791015625, rtl_math_StringFormat_F, 53, '.', - false, - "1.00000023841858000000000000000000000000000000000000000" }, - { 1.00000011920928955078125, rtl_math_StringFormat_F, 53, '.', - false, - "1.00000011920929000000000000000000000000000000000000000" }, - { 1.000000059604644775390625, rtl_math_StringFormat_F, 53, '.', - false, - "1.00000005960464000000000000000000000000000000000000000" }, - { 1.0000000298023223876953125, rtl_math_StringFormat_F, 53, '.', - false, - "1.00000002980232000000000000000000000000000000000000000" }, - { 1.00000001490116119384765625, rtl_math_StringFormat_F, 53, - '.', false, - "1.00000001490116000000000000000000000000000000000000000" }, - { 1.000000007450580596923828125, rtl_math_StringFormat_F, 53, - '.', false, - "1.00000000745058000000000000000000000000000000000000000" }, - { 1.0000000037252902984619140625, rtl_math_StringFormat_F, 53, - '.', false, - "1.00000000372529000000000000000000000000000000000000000" }, - { 1.00000000186264514923095703125, rtl_math_StringFormat_F, 53, - '.', false, - "1.00000000186265000000000000000000000000000000000000000" }, - { 1.000000000931322574615478515625, rtl_math_StringFormat_F, 53, - '.', false, - "1.00000000093132000000000000000000000000000000000000000" }, - { 1.0000000004656612873077392578125, rtl_math_StringFormat_F, - 53, '.', false, - "1.00000000046566000000000000000000000000000000000000000" }, - { 1.00000000023283064365386962890625, rtl_math_StringFormat_F, - 53, '.', false, - "1.00000000023283000000000000000000000000000000000000000" }, - { 1.000000000116415321826934814453125, rtl_math_StringFormat_F, - 53, '.', false, - "1.00000000011642000000000000000000000000000000000000000" }, - { 1.0000000000582076609134674072265625, rtl_math_StringFormat_F, - 53, '.', false, - "1.00000000005821000000000000000000000000000000000000000" }, - { 1.00000000002910383045673370361328125, - rtl_math_StringFormat_F, 53, '.', false, - "1.00000000002910000000000000000000000000000000000000000" }, - { 1.000000000014551915228366851806640625, - rtl_math_StringFormat_F, 53, '.', false, - "1.00000000001455000000000000000000000000000000000000000" }, - { 1.0000000000072759576141834259033203125, - rtl_math_StringFormat_F, 53, '.', false, - "1.00000000000728000000000000000000000000000000000000000" }, - { 1.00000000000363797880709171295166015625, - rtl_math_StringFormat_F, 53, '.', false, - "1.00000000000364000000000000000000000000000000000000000" }, - { 1.000000000001818989403545856475830078125, - rtl_math_StringFormat_F, 53, '.', false, - "1.00000000000182000000000000000000000000000000000000000" }, - { 1.0000000000009094947017729282379150390625, - rtl_math_StringFormat_F, 53, '.', false, - "1.00000000000091000000000000000000000000000000000000000" }, - { 1.00000000000045474735088646411895751953125, - rtl_math_StringFormat_F, 53, '.', false, - "1.00000000000045000000000000000000000000000000000000000" }, - { 1.000000000000227373675443232059478759765625, - rtl_math_StringFormat_F, 53, '.', false, - "1.00000000000023000000000000000000000000000000000000000" }, - { 1.0000000000001136868377216160297393798828125, - rtl_math_StringFormat_F, 53, '.', false, - "1.00000000000011000000000000000000000000000000000000000" }, - { 1.00000000000005684341886080801486968994140625, - rtl_math_StringFormat_F, 53, '.', false, - "1.00000000000006000000000000000000000000000000000000000" }, - { 1.000000000000028421709430404007434844970703125, - rtl_math_StringFormat_F, 53, '.', false, - "1.00000000000003000000000000000000000000000000000000000" }, - { 1.0000000000000142108547152020037174224853515625, - rtl_math_StringFormat_F, 53, '.', false, - "1.00000000000001000000000000000000000000000000000000000" }, - { 1.00000000000000710542735760100185871124267578125, - rtl_math_StringFormat_F, 53, '.', false, - "1.00000000000001000000000000000000000000000000000000000" }, - { 1.000000000000003552713678800500929355621337890625, - rtl_math_StringFormat_F, 53, '.', false, - "1.00000000000000000000000000000000000000000000000000000" }, - { 1.0000000000000017763568394002504646778106689453125, - rtl_math_StringFormat_F, 53, '.', false, - "1.00000000000000000000000000000000000000000000000000000" }, - { 1.00000000000000088817841970012523233890533447265625, - rtl_math_StringFormat_F, 53, '.', false, - "1.00000000000000000000000000000000000000000000000000000" }, - { 1.000000000000000444089209850062616169452667236328125, - rtl_math_StringFormat_F, 53, '.', false, - "1.00000000000000000000000000000000000000000000000000000" }, - { 1.0000000000000002220446049250313080847263336181640625, - rtl_math_StringFormat_F, 53, '.', false, - "1.00000000000000000000000000000000000000000000000000000" } }; - size_t const nCount = sizeof aTest / sizeof aTest[0]; - -//LLA: the float tests are wrong here, due to the fact that -// we calculate with too less digits after the point - -// bReturn &= testNumberToString< StringTraits, FloatTraits >( -// pTestResult, aTest, nCount); - bReturn &= testNumberToString< StringTraits, DoubleTraits >( - pTestResult, aTest, nCount); -// bReturn &= testNumberToString< UStringTraits, FloatTraits >( -// pTestResult, aTest, nCount); - bReturn &= testNumberToString< UStringTraits, DoubleTraits >( - pTestResult, aTest, nCount); - } - - { - static TestStringToNumberToString const aTest[] - = { { "1", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "1" }, - { " 1", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "1" }, - { " 1", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "1" }, - { "\t1", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "1" }, - { "\t 1", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "1" }, - { " \t1", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "1" }, - - { "-1", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "-1" }, - { " -1", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "-1" }, - { " -1", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "-1" }, - { "\t-1", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "-1" }, - { "\t -1", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "-1" }, - { " \t-1", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "-1" }, - - { "1.#INF", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', false, "1.#INF" }, - { " 1.#INF", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', false, "1.#INF" }, - { " 1.#INF", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', false, "1.#INF" }, - { "\t1.#INF", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', false, "1.#INF" }, - { "\t 1.#INF", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', false, "1.#INF" }, - { " \t1.#INF", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', false, "1.#INF" }, - - { "-1.#INF", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', false, "-1.#INF" }, - { " -1.#INF", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', false, "-1.#INF" }, - { " -1.#INF", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', false, "-1.#INF" }, - { "\t-1.#INF", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', false, "-1.#INF" }, - { "\t -1.#INF", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', false, "-1.#INF" }, - { " \t-1.#INF", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', false, "-1.#INF" }, - - { "1.#NAN", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', false, "1.#NAN" }, - { " 1.#NAN", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', false, "1.#NAN" }, - { " 1.#NAN", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', false, "1.#NAN" }, - { "\t1.#NAN", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', false, "1.#NAN" }, - { "\t 1.#NAN", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', false, "1.#NAN" }, - { " \t1.#NAN", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', false, "1.#NAN" }, - - { "-1.#NAN", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', false, "-1.#NAN" }, - { " -1.#NAN", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', false, "-1.#NAN" }, - { " -1.#NAN", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', false, "-1.#NAN" }, - { "\t-1.#NAN", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', false, "-1.#NAN" }, - { "\t -1.#NAN", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', false, "-1.#NAN" }, - { " \t-1.#NAN", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', false, "-1.#NAN" }, - - { "3.14E-2000", rtl_math_StringFormat_E, 4, '.', false, - "0.0000E+000" }, - { "3.14E-200", rtl_math_StringFormat_E, 4, '.', false, - "3.1400E-200" }, - { "3.14E-20", rtl_math_StringFormat_E, 4, '.', false, - "3.1400E-020" }, - { "3.14E-2", rtl_math_StringFormat_E, 4, '.', false, - "3.1400E-002" }, - { "3.14E2", rtl_math_StringFormat_E, 4, '.', false, - "3.1400E+002" }, - { "3.14E20", rtl_math_StringFormat_E, 4, '.', false, - "3.1400E+020" }, - { "3.14E200", rtl_math_StringFormat_E, 4, '.', false, - "3.1400E+200" }, - { "3.14E2000", rtl_math_StringFormat_E, 4, '.', false, - "1.#INF" }, - }; - size_t const nCount = sizeof aTest / sizeof aTest[0]; - bReturn &= testStringToNumberToString< StringTraits >( - pTestResult, aTest, nCount); - bReturn &= testStringToNumberToString< UStringTraits >( - pTestResult, aTest, nCount); - } - - return bReturn; -} - -// ----------------------------------------------------------------------------- -extern "C" void /* sal_Bool */ SAL_CALL test_rtl_math2( hTestResult hRtlTestResult ) -{ - c_rtl_tres_state_start(hRtlTestResult, "rtl_math" ); - - test_rtl_math( hRtlTestResult ); - - c_rtl_tres_state_end(hRtlTestResult, "rtl_math" ); -} -// ----------------------------------------------------------------------------- -void RegisterAdditionalFunctions(FktRegFuncPtr _pFunc) -{ - if (_pFunc) - { - (_pFunc)(&test_rtl_math2, ""); - } -} diff --git a/sal/qa/rtl/random/makefile.mk b/sal/qa/rtl/random/makefile.mk index cd57ec9bcc13..ef8616a90916 100644 --- a/sal/qa/rtl/random/makefile.mk +++ b/sal/qa/rtl/random/makefile.mk @@ -28,8 +28,6 @@ PRJ=..$/..$/.. PRJNAME=sal TARGET=qa_rtl_random -# this is removed at the moment because we need some enhancements -# TESTDIR=TRUE ENABLE_EXCEPTIONS=TRUE diff --git a/sal/qa/rtl_strings/makefile.mk b/sal/qa/rtl_strings/makefile.mk index 387f0675ace8..708a41a87887 100644 --- a/sal/qa/rtl_strings/makefile.mk +++ b/sal/qa/rtl_strings/makefile.mk @@ -28,7 +28,6 @@ PRJ=..$/.. PRJNAME=sal TARGET=qa_rtl_strings -# TESTDIR=TRUE ENABLE_EXCEPTIONS=TRUE diff --git a/sal/rtl/source/math.cxx b/sal/rtl/source/math.cxx index d983c5726230..34b940a301c9 100644 --- a/sal/rtl/source/math.cxx +++ b/sal/rtl/source/math.cxx @@ -923,7 +923,7 @@ inline double stringToDouble(CharT const * pBegin, CharT const * pEnd, if (pStatus != 0) *pStatus = eStatus; if (pParsedEnd != 0) - *pParsedEnd = p; + *pParsedEnd = p == p0 ? pBegin : p; return fVal; } diff --git a/sal/systools/win32/kill/kill.cxx b/sal/systools/win32/kill/kill.cxx index dd7ae85a0af2..ec1379ccfa6b 100644 --- a/sal/systools/win32/kill/kill.cxx +++ b/sal/systools/win32/kill/kill.cxx @@ -272,7 +272,7 @@ static void ParseCommandArgs( LPDWORD lpProcesses, LPDWORD lpdwNumProcesses, int { for ( int n = 0; n < NumSupportedSignals; n++ ) { - _tprintf( _T("%s "), SupportedSignals[n] ); + _tprintf( _T("%s "), SupportedSignals[n].lpSignalName ); } _tprintf( _T("\n") ); ExitProcess( 0 ); diff --git a/sal/textenc/convertiscii.tab b/sal/textenc/convertiscii.tab index 60672b8c0188..96f5dc8582c5 100644 --- a/sal/textenc/convertiscii.tab +++ b/sal/textenc/convertiscii.tab @@ -108,5 +108,5 @@ static ImplTextEncodingData const aImplIsciiDevanagariTextEncodingData 1, 1, NULL, - NULL, + "x-iscii-de", RTL_TEXTENCODING_INFO_ASCII }; diff --git a/sal/textenc/tencinfo.c b/sal/textenc/tencinfo.c index 0c51a98206e5..30a2fef0da72 100644 --- a/sal/textenc/tencinfo.c +++ b/sal/textenc/tencinfo.c @@ -910,6 +910,9 @@ rtl_TextEncoding SAL_CALL rtl_getTextEncodingFromMimeCharset( const sal_Char* pM { "csptcp154", RTL_TEXTENCODING_PT154 }, { "pt154", RTL_TEXTENCODING_PT154 }, { "cp154", RTL_TEXTENCODING_PT154 }, + { "xisciide", RTL_TEXTENCODING_ISCII_DEVANAGARI }, + /* This is no official MIME character set name, but is in use by + various windows APIs. */ { NULL, RTL_TEXTENCODING_DONTKNOW } }; @@ -1072,6 +1075,7 @@ rtl_getTextEncodingFromWindowsCodePage(sal_uInt32 nCodePage) case 51932: return RTL_TEXTENCODING_EUC_JP; case 51936: return RTL_TEXTENCODING_EUC_CN; case 51949: return RTL_TEXTENCODING_EUC_KR; + case 57002: return RTL_TEXTENCODING_ISCII_DEVANAGARI; case 65000: return RTL_TEXTENCODING_UTF7; case 65001: return RTL_TEXTENCODING_UTF8; default: return RTL_TEXTENCODING_DONTKNOW; @@ -1147,6 +1151,7 @@ rtl_getWindowsCodePageFromTextEncoding(rtl_TextEncoding nEncoding) case RTL_TEXTENCODING_EUC_JP: return 51932; case RTL_TEXTENCODING_EUC_CN: return 51936; case RTL_TEXTENCODING_EUC_KR: return 51949; + case RTL_TEXTENCODING_ISCII_DEVANAGARI: return 57002; case RTL_TEXTENCODING_UTF7: return 65000; case RTL_TEXTENCODING_UTF8: return 65001; default: return 0; |