summaryrefslogtreecommitdiff
path: root/sal/qa/rtl/oustring
diff options
context:
space:
mode:
Diffstat (limited to 'sal/qa/rtl/oustring')
-rw-r--r--sal/qa/rtl/oustring/joblist.txt10
-rw-r--r--sal/qa/rtl/oustring/makefile.mk82
-rw-r--r--sal/qa/rtl/oustring/rtl_OUString2.cxx1280
-rw-r--r--sal/qa/rtl/oustring/rtl_ustr.cxx1424
-rw-r--r--sal/qa/rtl/oustring/rtl_ustr.xsce33
5 files changed, 2829 insertions, 0 deletions
diff --git a/sal/qa/rtl/oustring/joblist.txt b/sal/qa/rtl/oustring/joblist.txt
new file mode 100644
index 000000000000..5d52da1e3008
--- /dev/null
+++ b/sal/qa/rtl/oustring/joblist.txt
@@ -0,0 +1,10 @@
+# JobFile for rtl_OUString
+# header source sal/inc/rtl/ustring.hxx
+
+rtl_OUString.valueOf.valueOf_double_001
+rtl_OUString.valueOf.valueOf_double_002
+rtl_OUString.valueOf.valueOf_double_003
+rtl_OUString.valueOf.valueOf_double_004
+rtl_OUString.valueOf.valueOf_double_005
+rtl_OUString.valueOf.valueOf_double_006
+rtl_OUString.valueOf.valueOf_double_007
diff --git a/sal/qa/rtl/oustring/makefile.mk b/sal/qa/rtl/oustring/makefile.mk
new file mode 100644
index 000000000000..6f15637651c6
--- /dev/null
+++ b/sal/qa/rtl/oustring/makefile.mk
@@ -0,0 +1,82 @@
+#*************************************************************************
+#
+# 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.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+INCPRE+= $(PRJ)$/qa$/inc
+
+PRJNAME=sal
+TARGET=rtl_oustring2
+
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+CFLAGS+= $(LFS_CFLAGS)
+CXXFLAGS+= $(LFS_CFLAGS)
+
+CFLAGSCXX += $(CPPUNIT_CFLAGS)
+
+# BEGIN ----------------------------------------------------------------
+# auto generated Target:joblist by codegen.pl
+SHL1OBJS= \
+ $(SLO)$/rtl_OUString2.obj
+
+SHL1TARGET= rtl_OUString2
+SHL1STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB)
+
+SHL1IMPLIB= i$(SHL1TARGET)
+# SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME =$(SHL1TARGET)
+# DEF1EXPORTFILE= export.exp
+SHL1VERSIONMAP= $(PRJ)$/qa$/export.map
+# auto generated Target:joblist
+# END ------------------------------------------------------------------
+
+# BEGIN ----------------------------------------------------------------
+SHL2OBJS= \
+ $(SLO)$/rtl_ustr.obj
+
+SHL2TARGET= rtl_ustr
+SHL2STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB)
+
+SHL2IMPLIB= i$(SHL2TARGET)
+DEF2NAME =$(SHL2TARGET)
+SHL2VERSIONMAP= $(PRJ)$/qa$/export.map
+# END ------------------------------------------------------------------
+
+#------------------------------- All object files -------------------------------
+# do this here, so we get right dependencies
+# SLOFILES=$(SHL1OBJS)
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+.INCLUDE : _cppunit.mk
+
diff --git a/sal/qa/rtl/oustring/rtl_OUString2.cxx b/sal/qa/rtl/oustring/rtl_OUString2.cxx
new file mode 100644
index 000000000000..878f42713278
--- /dev/null
+++ b/sal/qa/rtl/oustring/rtl_OUString2.cxx
@@ -0,0 +1,1280 @@
+/*************************************************************************
+ *
+ * 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"
+// autogenerated file with codegen.pl
+
+#include <math.h>
+#include <stdio.h>
+
+#include <algorithm> // STL
+
+#include <testshl/simpleheader.hxx>
+#include "stringhelper.hxx"
+#include "valueequal.hxx"
+
+inline void printOUString( ::rtl::OUString const & _suStr )
+{
+ rtl::OString aString;
+
+ t_print( "OUString: " );
+ aString = ::rtl::OUStringToOString( _suStr, RTL_TEXTENCODING_ASCII_US );
+ t_print( "'%s'\n", aString.getStr( ) );
+}
+
+namespace rtl_OUString
+{
+
+ class ctors_rtl_uString : public CppUnit::TestFixture
+ {
+
+ public:
+ /// test of OUString(rtl_uString*)
+ void ctors_001()
+ {
+ rtl::OUString *pStr = new rtl::OUString( rtl::OUString::createFromAscii("a String") );
+
+ rtl::OUString aStrToTest(pStr->pData);
+ delete pStr;
+
+ // maybe here should we do something with current memory
+ char* pBuffer = (char*) malloc(2 * 8);
+ memset(pBuffer, 0, 2 * 8);
+ free(pBuffer);
+
+ sal_Bool bResult = aStrToTest.equals(rtl::OUString::createFromAscii("a String"));
+ CPPUNIT_ASSERT_MESSAGE("String must not be empty", bResult == sal_True);
+ }
+
+ // 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(ctors_rtl_uString);
+ CPPUNIT_TEST(ctors_001);
+ CPPUNIT_TEST_SUITE_END();
+ };
+
+// -----------------------------------------------------------------------------
+class valueOf : public CppUnit::TestFixture
+{
+ void valueOf_float_test_impl(float _nValue)
+ {
+ rtl::OUString suValue;
+ suValue = rtl::OUString::valueOf( _nValue );
+ rtl::OString sValue;
+ sValue <<= suValue;
+ t_print(T_VERBOSE, "nFloat := %.9f sValue := %s\n", _nValue, sValue.getStr());
+
+ float nValueATOF = static_cast<float>(atof( sValue.getStr() ));
+
+ bool bEqualResult = is_float_equal(_nValue, nValueATOF);
+ CPPUNIT_ASSERT_MESSAGE("Values are not equal.", bEqualResult == true);
+ }
+
+ void valueOf_float_test(float _nValue)
+ {
+ valueOf_float_test_impl(_nValue);
+
+ // test also the negative part.
+ float nNegativeValue = -_nValue;
+ valueOf_float_test_impl(nNegativeValue);
+ }
+
+public:
+ // insert your test code here.
+ void valueOf_float_test_001()
+ {
+ // this is demonstration code
+ // CPPUNIT_ASSERT_MESSAGE("a message", 1 == 1);
+ float nValue = 3.0f;
+ valueOf_float_test(nValue);
+ }
+
+ void valueOf_float_test_002()
+ {
+ float nValue = 3.5f;
+ valueOf_float_test(nValue);
+ }
+
+ void valueOf_float_test_003()
+ {
+ float nValue = 3.0625f;
+ valueOf_float_test(nValue);
+ }
+
+ void valueOf_float_test_004()
+ {
+ float nValue = 3.502525f;
+ valueOf_float_test(nValue);
+ }
+
+ void valueOf_float_test_005()
+ {
+ float nValue = 3.141592f;
+ valueOf_float_test(nValue);
+ }
+
+ void valueOf_float_test_006()
+ {
+ float nValue = 3.5025255f;
+ valueOf_float_test(nValue);
+ }
+
+ void valueOf_float_test_007()
+ {
+ float nValue = 3.0039062f;
+ valueOf_float_test(nValue);
+ }
+
+private:
+
+ void valueOf_double_test_impl(double _nValue)
+ {
+ rtl::OUString suValue;
+ suValue = rtl::OUString::valueOf( _nValue );
+ rtl::OString sValue;
+ sValue <<= suValue;
+ t_print(T_VERBOSE, "nDouble := %.20f sValue := %s\n", _nValue, sValue.getStr());
+
+ double nValueATOF = atof( sValue.getStr() );
+
+ bool bEqualResult = is_double_equal(_nValue, nValueATOF);
+ CPPUNIT_ASSERT_MESSAGE("Values are not equal.", bEqualResult == true);
+ }
+
+ void valueOf_double_test(double _nValue)
+ {
+ valueOf_double_test_impl(_nValue);
+
+ // test also the negative part.
+ double nNegativeValue = -_nValue;
+ valueOf_double_test_impl(nNegativeValue);
+ }
+public:
+
+ // valueOf double
+ void valueOf_double_test_001()
+ {
+ double nValue = 3.0;
+ valueOf_double_test(nValue);
+ }
+ void valueOf_double_test_002()
+ {
+ double nValue = 3.5;
+ valueOf_double_test(nValue);
+ }
+ void valueOf_double_test_003()
+ {
+ double nValue = 3.0625;
+ valueOf_double_test(nValue);
+ }
+ void valueOf_double_test_004()
+ {
+ double nValue = 3.1415926535;
+ valueOf_double_test(nValue);
+ }
+ void valueOf_double_test_005()
+ {
+ double nValue = 3.141592653589793;
+ valueOf_double_test(nValue);
+ }
+ void valueOf_double_test_006()
+ {
+ double nValue = 3.1415926535897932;
+ valueOf_double_test(nValue);
+ }
+ void valueOf_double_test_007()
+ {
+ double nValue = 3.14159265358979323;
+ valueOf_double_test(nValue);
+ }
+ void valueOf_double_test_008()
+ {
+ double nValue = 3.141592653589793238462643;
+ valueOf_double_test(nValue);
+ }
+
+
+ // 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(valueOf);
+ CPPUNIT_TEST(valueOf_float_test_001);
+ CPPUNIT_TEST(valueOf_float_test_002);
+ CPPUNIT_TEST(valueOf_float_test_003);
+ CPPUNIT_TEST(valueOf_float_test_004);
+ CPPUNIT_TEST(valueOf_float_test_005);
+ CPPUNIT_TEST(valueOf_float_test_006);
+ CPPUNIT_TEST(valueOf_float_test_007);
+
+ CPPUNIT_TEST(valueOf_double_test_001);
+ CPPUNIT_TEST(valueOf_double_test_002);
+ CPPUNIT_TEST(valueOf_double_test_003);
+ CPPUNIT_TEST(valueOf_double_test_004);
+ CPPUNIT_TEST(valueOf_double_test_005);
+ CPPUNIT_TEST(valueOf_double_test_006);
+ CPPUNIT_TEST(valueOf_double_test_007);
+ CPPUNIT_TEST(valueOf_double_test_008);
+ CPPUNIT_TEST_SUITE_END();
+}; // class valueOf
+
+//------------------------------------------------------------------------
+// testing the method toDouble()
+//------------------------------------------------------------------------
+template<class T>
+sal_Int16 SAL_CALL checkPrecisionSize()
+{
+ // sal_Int16 nSize = sizeof(T);
+ volatile T nCalcValue = 1.0;
+
+
+ // (i + 1) is the current precision
+ // numerical series
+ // 1.1
+ // 10.1
+ // 100.1
+ // ...
+ // 1000...0.1
+
+ sal_Int16 i = 0;
+ for (i=0;i<50;i++)
+ {
+ nCalcValue *= 10;
+ volatile T nValue = nCalcValue + static_cast<T>(0.1);
+ volatile T dSub = nValue - nCalcValue;
+ // ----- 0.11 ---- 0.1 ---- 0.09 -----
+ if (0.11 > dSub && dSub < 0.09)
+ {
+ // due to the fact, that the value is break down we sub 1 from the precision value
+ // but to suppress this, we start at zero, precision is i+1 till here --i;
+ break;
+ }
+ }
+
+ sal_Int16 j= 0;
+ nCalcValue = 1.0;
+
+ // numerical series
+ // 1.1
+ // 1.01
+ // 1.001
+ // ...
+ // 1.000...001
+
+ for (j=0;j<50;j++)
+ {
+ nCalcValue /= 10;
+ volatile T nValue = nCalcValue + static_cast<T>(1.0);
+ volatile T dSub = nValue - static_cast<T>(1.0);
+ // ---- 0.02 ----- 0.01 ---- 0 --- -0.99 ---- -0.98 ----
+ // volatile T dSubAbsolut = fabs(dSub);
+ // ---- 0.02 ----- 0.01 ---- 0 (cut)
+ if ( dSub == 0)
+ break;
+ }
+ if (i != j)
+ {
+ // hmmm....
+ // imho i +- 1 == j is a good value
+ int n = i - j;
+ if (n < 0) n = -n;
+ if (n <= 1)
+ {
+ return std::min(i,j);
+ }
+ else
+ {
+ t_print("warning: presision differs more than 1!\n");
+ }
+ }
+
+ return i;
+}
+
+// -----------------------------------------------------------------------------
+
+ class testPrecision
+ {
+ public:
+ testPrecision()
+ {
+ sal_Int16 nPrecision;
+ nPrecision = checkPrecisionSize<float>();
+ t_print("precision of float: %d sizeof()=%d \n", nPrecision, sizeof(float));
+
+ nPrecision = checkPrecisionSize<double>();
+ t_print("precision of double: %d sizeof()=%d \n", nPrecision, sizeof(double));
+
+ nPrecision = checkPrecisionSize<long double>();
+ t_print("precision of long double: %d sizeof()=%d \n", nPrecision, sizeof(long double));
+
+ }
+
+ };
+
+ class toInt: public CppUnit::TestFixture {
+ public:
+ void test() {
+ CPPUNIT_ASSERT_EQUAL(
+ static_cast< sal_Int32 >(-0x76543210),
+ (rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-76543210")).
+ toInt32(16)));
+ CPPUNIT_ASSERT_EQUAL(
+ static_cast< sal_Int32 >(0xFEDCBA98),
+ (rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("+FEDCBA98")).
+ toInt32(16)));
+ CPPUNIT_ASSERT_EQUAL(
+ static_cast< sal_Int64 >(-SAL_CONST_INT64(0x76543210FEDCBA98)),
+ (rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("-76543210FEDCBA98")).
+ toInt64(16)));
+ CPPUNIT_ASSERT_EQUAL(
+ static_cast< sal_Int64 >(SAL_CONST_INT64(0xFEDCBA9876543210)),
+ (rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("+FEDCBA9876543210")).
+ toInt64(16)));
+ }
+
+ CPPUNIT_TEST_SUITE(toInt);
+ CPPUNIT_TEST(test);
+ CPPUNIT_TEST_SUITE_END();
+ };
+
+// -----------------------------------------------------------------------------
+// - toDouble (tests)
+// -----------------------------------------------------------------------------
+ class toDouble : public CppUnit::TestFixture
+ {
+ public:
+ void toDouble_test_impl(rtl::OString const& _sValue)
+ {
+ //t_print("the original str is %s\n", _sValue.getStr());
+ double nValueATOF = atof( _sValue.getStr() );
+ //t_print("original data is %e\n", nValueATOF);
+ rtl::OUString suValue = rtl::OUString::createFromAscii( _sValue.getStr() );
+ double nValueToDouble = suValue.toDouble();
+ //t_print("result data is %e\n", nValueToDouble);
+
+ bool bEqualResult = is_double_equal(nValueToDouble, nValueATOF);
+ CPPUNIT_ASSERT_MESSAGE("Values are not equal.", bEqualResult == true);
+ }
+
+ void toDouble_test(rtl::OString const& _sValue)
+ {
+ toDouble_test_impl(_sValue);
+
+ // test also the negativ part.
+ rtl::OString sNegativValue("-");
+ sNegativValue += _sValue;
+ toDouble_test_impl(sNegativValue);
+ }
+
+ // insert your test code here.
+ void toDouble_selftest()
+ {
+ t_print("Start selftest:\n");
+ CPPUNIT_ASSERT (is_double_equal(1.0, 1.01) == false);
+ CPPUNIT_ASSERT (is_double_equal(1.0, 1.001) == false);
+ CPPUNIT_ASSERT (is_double_equal(1.0, 1.0001) == false);
+ CPPUNIT_ASSERT (is_double_equal(1.0, 1.00001) == false);
+ CPPUNIT_ASSERT (is_double_equal(1.0, 1.000001) == false);
+ CPPUNIT_ASSERT (is_double_equal(1.0, 1.0000001) == false);
+ CPPUNIT_ASSERT (is_double_equal(1.0, 1.00000001) == false);
+ CPPUNIT_ASSERT (is_double_equal(1.0, 1.000000001) == false);
+ CPPUNIT_ASSERT (is_double_equal(1.0, 1.0000000001) == false);
+ CPPUNIT_ASSERT (is_double_equal(1.0, 1.00000000001) == false);
+ CPPUNIT_ASSERT (is_double_equal(1.0, 1.000000000001) == false);
+ CPPUNIT_ASSERT (is_double_equal(1.0, 1.0000000000001) == false);
+ // we check til 15 values after comma
+ CPPUNIT_ASSERT (is_double_equal(1.0, 1.00000000000001) == true);
+ CPPUNIT_ASSERT (is_double_equal(1.0, 1.000000000000001) == true);
+ CPPUNIT_ASSERT (is_double_equal(1.0, 1.0000000000000001) == true);
+ t_print("Selftest done.\n");
+ }
+
+ void toDouble_test_3()
+ {
+ rtl::OString sValue("3");
+ toDouble_test(sValue);
+ }
+ void toDouble_test_3_5()
+ {
+ rtl::OString sValue("3.5");
+ toDouble_test(sValue);
+ }
+ void toDouble_test_3_0625()
+ {
+ rtl::OString sValue("3.0625");
+ toDouble_test(sValue);
+ }
+ void toDouble_test_pi()
+ {
+ // value from http://www.angio.net/pi/digits/50.txt
+ rtl::OString sValue("3.141592653589793238462643383279502884197169399375");
+ toDouble_test(sValue);
+ }
+
+ void toDouble_test_1()
+ {
+ rtl::OString sValue("1");
+ toDouble_test(sValue);
+ }
+ void toDouble_test_10()
+ {
+ rtl::OString sValue("10");
+ toDouble_test(sValue);
+ }
+ void toDouble_test_100()
+ {
+ rtl::OString sValue("100");
+ toDouble_test(sValue);
+ }
+ void toDouble_test_1000()
+ {
+ rtl::OString sValue("1000");
+ toDouble_test(sValue);
+ }
+ void toDouble_test_10000()
+ {
+ rtl::OString sValue("10000");
+ toDouble_test(sValue);
+ }
+ void toDouble_test_1e99()
+ {
+ rtl::OString sValue("1e99");
+ toDouble_test(sValue);
+ }
+ void toDouble_test_1e_n99()
+ {
+ rtl::OString sValue("1e-99");
+ toDouble_test(sValue);
+ }
+ void toDouble_test_1e308()
+ {
+ rtl::OString sValue("1e308");
+ toDouble_test(sValue);
+ }
+
+ // 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(toDouble);
+ CPPUNIT_TEST(toDouble_selftest);
+
+ CPPUNIT_TEST(toDouble_test_3);
+ CPPUNIT_TEST(toDouble_test_3_5);
+ CPPUNIT_TEST(toDouble_test_3_0625);
+ CPPUNIT_TEST(toDouble_test_pi);
+ CPPUNIT_TEST(toDouble_test_1);
+ CPPUNIT_TEST(toDouble_test_10);
+ CPPUNIT_TEST(toDouble_test_100);
+ CPPUNIT_TEST(toDouble_test_1000);
+ CPPUNIT_TEST(toDouble_test_10000);
+ CPPUNIT_TEST(toDouble_test_1e99);
+ CPPUNIT_TEST(toDouble_test_1e_n99);
+ CPPUNIT_TEST(toDouble_test_1e308);
+ CPPUNIT_TEST_SUITE_END();
+ }; // class toDouble
+
+// -----------------------------------------------------------------------------
+// - toFloat (tests)
+// -----------------------------------------------------------------------------
+ class toFloat : public CppUnit::TestFixture
+ {
+ public:
+ void toFloat_test_impl(rtl::OString const& _sValue)
+ {
+ //t_print("the original str is %s\n", _sValue.getStr());
+ float nValueATOF = static_cast<float>(atof( _sValue.getStr() ));
+ //t_print("the original str is %.10f\n", nValueATOF);
+ rtl::OUString suValue = rtl::OUString::createFromAscii( _sValue.getStr() );
+ float nValueToFloat = suValue.toFloat();
+ //t_print("the result str is %.10f\n", nValueToFloat);
+
+ bool bEqualResult = is_float_equal(nValueToFloat, nValueATOF);
+ CPPUNIT_ASSERT_MESSAGE("Values are not equal.", bEqualResult == true);
+ }
+
+ void toFloat_test(rtl::OString const& _sValue)
+ {
+ toFloat_test_impl(_sValue);
+
+ // test also the negativ part.
+ rtl::OString sNegativValue("-");
+ sNegativValue += _sValue;
+ toFloat_test_impl(sNegativValue);
+ }
+
+ // insert your test code here.
+ void toFloat_selftest()
+ {
+ t_print("Start selftest:\n");
+ CPPUNIT_ASSERT (is_float_equal(1.0f, 1.01f) == false);
+ CPPUNIT_ASSERT (is_float_equal(1.0f, 1.001f) == false);
+ CPPUNIT_ASSERT (is_float_equal(1.0f, 1.0001f) == false);
+ CPPUNIT_ASSERT (is_float_equal(1.0f, 1.00001f) == false);
+ CPPUNIT_ASSERT (is_float_equal(1.0f, 1.000002f) == false);
+ CPPUNIT_ASSERT (is_float_equal(1.0f, 1.0000001f) == true);
+ CPPUNIT_ASSERT (is_float_equal(1.0f, 1.00000001f) == true);
+ CPPUNIT_ASSERT (is_float_equal(1.0f, 1.000000001f) == true);
+
+ t_print("Selftest done.\n");
+ }
+
+ void toFloat_test_3()
+ {
+ rtl::OString sValue("3");
+ toFloat_test(sValue);
+ }
+ void toFloat_test_3_5()
+ {
+ rtl::OString sValue("3.5");
+ toFloat_test(sValue);
+ }
+ void toFloat_test_3_0625()
+ {
+ rtl::OString sValue("3.0625");
+ toFloat_test(sValue);
+ }
+ void toFloat_test_3_0625_e()
+ {
+ rtl::OString sValue("3.0625e-4");
+ toFloat_test(sValue);
+ }
+ void toFloat_test_pi()
+ {
+ // value from http://www.angio.net/pi/digits/50.txt
+ rtl::OString sValue("3.141592653589793238462643383279502884197169399375");
+ toFloat_test(sValue);
+ }
+
+ void toFloat_test_1()
+ {
+ rtl::OString sValue("1");
+ toFloat_test(sValue);
+ }
+ void toFloat_test_10()
+ {
+ rtl::OString sValue("10");
+ toFloat_test(sValue);
+ }
+ void toFloat_test_100()
+ {
+ rtl::OString sValue("100");
+ toFloat_test(sValue);
+ }
+ void toFloat_test_1000()
+ {
+ rtl::OString sValue("1000");
+ toFloat_test(sValue);
+ }
+ void toFloat_test_10000()
+ {
+ rtl::OString sValue("10000");
+ toFloat_test(sValue);
+ }
+ void toFloat_test_mix()
+ {
+ rtl::OString sValue("456789321455.123456789012");
+ toFloat_test(sValue);
+ }
+ void toFloat_test_1e99()
+ {
+ rtl::OString sValue("1e99");
+ toFloat_test(sValue);
+ }
+ void toFloat_test_1e_n99()
+ {
+ rtl::OString sValue("1e-9");
+ toFloat_test(sValue);
+ }
+ void toFloat_test_1e308()
+ {
+ rtl::OString sValue("1e308");
+ toFloat_test(sValue);
+ }
+
+ // 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(toFloat);
+ CPPUNIT_TEST(toFloat_selftest);
+
+ CPPUNIT_TEST(toFloat_test_3);
+ CPPUNIT_TEST(toFloat_test_3_5);
+ CPPUNIT_TEST(toFloat_test_3_0625);
+ CPPUNIT_TEST(toFloat_test_3_0625_e);
+ CPPUNIT_TEST(toFloat_test_pi);
+ CPPUNIT_TEST(toFloat_test_1);
+ CPPUNIT_TEST(toFloat_test_10);
+ CPPUNIT_TEST(toFloat_test_100);
+ CPPUNIT_TEST(toFloat_test_1000);
+ CPPUNIT_TEST(toFloat_test_10000);
+ CPPUNIT_TEST(toFloat_test_mix);
+ CPPUNIT_TEST(toFloat_test_1e99);
+ CPPUNIT_TEST(toFloat_test_1e_n99);
+ CPPUNIT_TEST(toFloat_test_1e308);
+ CPPUNIT_TEST_SUITE_END();
+ }; // class toFloat
+
+// -----------------------------------------------------------------------------
+// - lastIndexOf (tests)
+// -----------------------------------------------------------------------------
+class lastIndexOf : public CppUnit::TestFixture
+{
+
+public:
+ void lastIndexOf_oustring(rtl::OUString const& _suStr, rtl::OUString const& _suSearchStr, sal_Int32 _nExpectedResultPos)
+ {
+ // Algorithm
+ // search the string _suSearchStr (rtl::OUString) in the string _suStr.
+ // check if the _nExpectedResultPos occurs.
+
+ sal_Int32 nPos = _suStr.lastIndexOf(_suSearchStr);
+ CPPUNIT_ASSERT_MESSAGE("expected position is wrong", nPos == _nExpectedResultPos);
+ }
+
+ void lastIndexOf_salunicode(rtl::OUString const& _suStr, sal_Unicode _cuSearchChar, sal_Int32 _nExpectedResultPos)
+ {
+ // Algorithm
+ // search the unicode char _suSearchChar (sal_Unicode) in the string _suStr.
+ // check if the _nExpectedResultPos occurs.
+
+ sal_Int32 nPos = _suStr.lastIndexOf(_cuSearchChar);
+ CPPUNIT_ASSERT_MESSAGE("expected position is wrong", nPos == _nExpectedResultPos);
+ }
+
+ void lastIndexOf_oustring_offset(rtl::OUString const& _suStr, rtl::OUString const& _suSearchStr, sal_Int32 _nExpectedResultPos, sal_Int32 _nStartOffset)
+ {
+ sal_Int32 nPos = _suStr.lastIndexOf(_suSearchStr, _nStartOffset);
+ CPPUNIT_ASSERT_MESSAGE("expected position is wrong", nPos == _nExpectedResultPos);
+ }
+
+ void lastIndexOf_salunicode_offset(rtl::OUString const& _suStr, sal_Unicode _cuSearchChar, sal_Int32 _nExpectedResultPos, sal_Int32 _nStartOffset)
+ {
+ sal_Int32 nPos = _suStr.lastIndexOf(_cuSearchChar, _nStartOffset);
+ CPPUNIT_ASSERT_MESSAGE("expected position is wrong", nPos == _nExpectedResultPos);
+ }
+
+ // -----------------------------------------------------------------------------
+
+ void lastIndexOf_test_oustring_offset_001()
+ {
+ // search for sun, start at the end, found (pos==0)
+ rtl::OUString aStr = rtl::OUString::createFromAscii("sun java system");
+ rtl::OUString aSearchStr = rtl::OUString::createFromAscii("sun");
+ lastIndexOf_oustring_offset(aStr, aSearchStr, 0, aStr.getLength());
+ }
+
+ void lastIndexOf_test_oustring_offset_002()
+ {
+ // search for sun, start at pos = 3, found (pos==0)
+ rtl::OUString aStr = rtl::OUString::createFromAscii("sun java system");
+ rtl::OUString aSearchStr = rtl::OUString::createFromAscii("sun");
+ lastIndexOf_oustring_offset(aStr, aSearchStr, 0, 3);
+ }
+
+ void lastIndexOf_test_oustring_offset_003()
+ {
+ // search for sun, start at pos = 2, found (pos==-1)
+ rtl::OUString aStr = rtl::OUString::createFromAscii("sun java system");
+ rtl::OUString aSearchStr = rtl::OUString::createFromAscii("sun");
+ lastIndexOf_oustring_offset(aStr, aSearchStr, -1, 2);
+ }
+
+ void lastIndexOf_test_oustring_offset_004()
+ {
+ // search for sun, start at the end, found (pos==0)
+ rtl::OUString aStr = rtl::OUString::createFromAscii("sun java system");
+ rtl::OUString aSearchStr = rtl::OUString::createFromAscii("sun");
+ lastIndexOf_oustring_offset(aStr, aSearchStr, -1, -1);
+ }
+
+ void lastIndexOf_test_oustring_001()
+ {
+ // search for sun, found (pos==0)
+ rtl::OUString aStr = rtl::OUString::createFromAscii("sun java system");
+ rtl::OUString aSearchStr = rtl::OUString::createFromAscii("sun");
+ lastIndexOf_oustring(aStr, aSearchStr, 0);
+ }
+
+ void lastIndexOf_test_oustring_002()
+ {
+ // search for sun, found (pos==4)
+ rtl::OUString aStr = rtl::OUString::createFromAscii("the sun java system");
+ rtl::OUString aSearchStr = rtl::OUString::createFromAscii("sun");
+ lastIndexOf_oustring(aStr, aSearchStr, 4);
+ }
+
+ void lastIndexOf_test_oustring_003()
+ {
+ // search for sun, found (pos==8)
+ rtl::OUString aStr = rtl::OUString::createFromAscii("the sun sun java system");
+ rtl::OUString aSearchStr = rtl::OUString::createFromAscii("sun");
+ lastIndexOf_oustring(aStr, aSearchStr, 8);
+ }
+
+ void lastIndexOf_test_oustring_004()
+ {
+ // search for sun, found (pos==8)
+ rtl::OUString aStr = rtl::OUString::createFromAscii("the sun sun");
+ rtl::OUString aSearchStr = rtl::OUString::createFromAscii("sun");
+ lastIndexOf_oustring(aStr, aSearchStr, 8);
+ }
+
+ void lastIndexOf_test_oustring_005()
+ {
+ // search for sun, found (pos==4)
+ rtl::OUString aStr = rtl::OUString::createFromAscii("the sun su");
+ rtl::OUString aSearchStr = rtl::OUString::createFromAscii("sun");
+ lastIndexOf_oustring(aStr, aSearchStr, 4);
+ }
+
+ void lastIndexOf_test_oustring_006()
+ {
+ // search for sun, found (pos==-1)
+ rtl::OUString aStr = rtl::OUString::createFromAscii("the su su");
+ rtl::OUString aSearchStr = rtl::OUString::createFromAscii("sun");
+ lastIndexOf_oustring(aStr, aSearchStr, -1);
+ }
+
+ void lastIndexOf_test_oustring_007()
+ {
+ // search for earth, not found (-1)
+ rtl::OUString aStr = rtl::OUString::createFromAscii("the su su");
+ rtl::OUString aSearchStr = rtl::OUString::createFromAscii("earth");
+ lastIndexOf_oustring(aStr, aSearchStr, -1);
+ }
+
+ void lastIndexOf_test_oustring_008()
+ {
+ // search for earth, not found (-1)
+ rtl::OUString aStr = rtl::OUString();
+ rtl::OUString aSearchStr = rtl::OUString::createFromAscii("earth");
+ lastIndexOf_oustring(aStr, aSearchStr, -1);
+ }
+
+ void lastIndexOf_test_oustring_009()
+ {
+ // search for earth, not found (-1)
+ rtl::OUString aStr = rtl::OUString();
+ rtl::OUString aSearchStr = rtl::OUString();
+ lastIndexOf_oustring(aStr, aSearchStr, -1);
+
+ }
+
+ void lastIndexOf_test_salunicode_001()
+ {
+ // search for 's', found (19)
+ rtl::OUString aStr = rtl::OUString::createFromAscii("the sun sun java system");
+ sal_Unicode suChar = L's';
+ lastIndexOf_salunicode(aStr, suChar, 19);
+ }
+
+ void lastIndexOf_test_salunicode_002()
+ {
+ // search for 'x', not found (-1)
+ rtl::OUString aStr = rtl::OUString::createFromAscii("the sun sun java system");
+ sal_Unicode suChar = L'x';
+ lastIndexOf_salunicode(aStr, suChar, -1);
+ }
+
+ void lastIndexOf_test_salunicode_offset_001()
+ {
+ // search for 's', start from pos last char, found (19)
+ rtl::OUString aStr = rtl::OUString::createFromAscii("the sun sun java system");
+ sal_Unicode cuChar = L's';
+ lastIndexOf_salunicode_offset(aStr, cuChar, 19, aStr.getLength());
+ }
+ void lastIndexOf_test_salunicode_offset_002()
+ {
+ // search for 's', start pos is last occur from search behind, found (17)
+ rtl::OUString aStr = rtl::OUString::createFromAscii("the sun sun java system");
+ sal_Unicode cuChar = L's';
+ lastIndexOf_salunicode_offset(aStr, cuChar, 17, 19);
+ }
+ void lastIndexOf_test_salunicode_offset_003()
+ {
+ // search for 't', start pos is 1, found (0)
+ rtl::OUString aStr = rtl::OUString::createFromAscii("the sun sun java system");
+ sal_Unicode cuChar = L't';
+ lastIndexOf_salunicode_offset(aStr, cuChar, 0, 1);
+ }
+
+ // 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(lastIndexOf);
+ CPPUNIT_TEST(lastIndexOf_test_oustring_001);
+ CPPUNIT_TEST(lastIndexOf_test_oustring_002);
+ CPPUNIT_TEST(lastIndexOf_test_oustring_003);
+ CPPUNIT_TEST(lastIndexOf_test_oustring_004);
+ CPPUNIT_TEST(lastIndexOf_test_oustring_005);
+ CPPUNIT_TEST(lastIndexOf_test_oustring_006);
+ CPPUNIT_TEST(lastIndexOf_test_oustring_007);
+ CPPUNIT_TEST(lastIndexOf_test_oustring_008);
+ CPPUNIT_TEST(lastIndexOf_test_oustring_009);
+
+ CPPUNIT_TEST(lastIndexOf_test_oustring_offset_001);
+ CPPUNIT_TEST(lastIndexOf_test_oustring_offset_002);
+ CPPUNIT_TEST(lastIndexOf_test_oustring_offset_003);
+ CPPUNIT_TEST(lastIndexOf_test_oustring_offset_004);
+
+ CPPUNIT_TEST(lastIndexOf_test_salunicode_001);
+ CPPUNIT_TEST(lastIndexOf_test_salunicode_002);
+
+ CPPUNIT_TEST(lastIndexOf_test_salunicode_offset_001);
+ CPPUNIT_TEST(lastIndexOf_test_salunicode_offset_002);
+ CPPUNIT_TEST(lastIndexOf_test_salunicode_offset_003);
+
+ CPPUNIT_TEST_SUITE_END();
+}; // class lastIndexOf
+
+
+// -----------------------------------------------------------------------------
+// - getToken (tests)
+// -----------------------------------------------------------------------------
+class getToken : public CppUnit::TestFixture
+{
+
+public:
+ void getToken_000()
+ {
+ rtl::OUString suTokenStr;
+
+ sal_Int32 nIndex = 0;
+ do
+ {
+ rtl::OUString suToken = suTokenStr.getToken( 0, ';', nIndex );
+ }
+ while ( nIndex >= 0 );
+ t_print("Index %d\n", nIndex);
+ // should not GPF
+ }
+
+ void getToken_001()
+ {
+ rtl::OUString suTokenStr = rtl::OUString::createFromAscii("a;b");
+
+ sal_Int32 nIndex = 0;
+
+ rtl::OUString suToken = suTokenStr.getToken( 0, ';', nIndex );
+ CPPUNIT_ASSERT_MESSAGE("Token should be a 'a'", suToken.equals(rtl::OUString::createFromAscii("a")) == sal_True);
+
+ /* rtl::OUString */ suToken = suTokenStr.getToken( 0, ';', nIndex );
+ CPPUNIT_ASSERT_MESSAGE("Token should be a 'b'", suToken.equals(rtl::OUString::createFromAscii("b")) == sal_True);
+ CPPUNIT_ASSERT_MESSAGE("index should be negative", nIndex == -1);
+ }
+
+ void getToken_002()
+ {
+ rtl::OUString suTokenStr = rtl::OUString::createFromAscii("a;b.c");
+
+ sal_Int32 nIndex = 0;
+
+ rtl::OUString suToken = suTokenStr.getToken( 0, ';', nIndex );
+ CPPUNIT_ASSERT_MESSAGE("Token should be a 'a'", suToken.equals(rtl::OUString::createFromAscii("a")) == sal_True);
+
+ /* rtl::OUString */ suToken = suTokenStr.getToken( 0, '.', nIndex );
+ CPPUNIT_ASSERT_MESSAGE("Token should be a 'b'", suToken.equals(rtl::OUString::createFromAscii("b")) == sal_True);
+
+ /* rtl::OUString */ suToken = suTokenStr.getToken( 0, '.', nIndex );
+ CPPUNIT_ASSERT_MESSAGE("Token should be a 'c'", suToken.equals(rtl::OUString::createFromAscii("c")) == sal_True);
+ CPPUNIT_ASSERT_MESSAGE("index should be negative", nIndex == -1);
+ }
+
+ void getToken_003()
+ {
+ rtl::OUString suTokenStr = rtl::OUString::createFromAscii("a;;b");
+
+ sal_Int32 nIndex = 0;
+
+ rtl::OUString suToken = suTokenStr.getToken( 0, ';', nIndex );
+ CPPUNIT_ASSERT_MESSAGE("Token should be a 'a'", suToken.equals(rtl::OUString::createFromAscii("a")) == sal_True);
+
+ /* rtl::OUString */ suToken = suTokenStr.getToken( 0, ';', nIndex );
+ CPPUNIT_ASSERT_MESSAGE("Token should be empty", suToken.getLength() == 0);
+
+ /* rtl::OUString */ suToken = suTokenStr.getToken( 0, ';', nIndex );
+ CPPUNIT_ASSERT_MESSAGE("Token should be a 'b'", suToken.equals(rtl::OUString::createFromAscii("b")) == sal_True);
+ CPPUNIT_ASSERT_MESSAGE("index should be negative", nIndex == -1);
+ }
+
+ void getToken_004()
+ {
+ rtl::OUString suTokenStr = rtl::OUString::createFromAscii("longer.then.ever.");
+
+ sal_Int32 nIndex = 0;
+
+ rtl::OUString suToken = suTokenStr.getToken( 0, '.', nIndex );
+ CPPUNIT_ASSERT_MESSAGE("Token should be 'longer'", suToken.equals(rtl::OUString::createFromAscii("longer")) == sal_True);
+
+ /* rtl::OUString */ suToken = suTokenStr.getToken( 0, '.', nIndex );
+ CPPUNIT_ASSERT_MESSAGE("Token should be 'then'", suToken.equals(rtl::OUString::createFromAscii("then")) == sal_True);
+
+ /* rtl::OUString */ suToken = suTokenStr.getToken( 0, '.', nIndex );
+ CPPUNIT_ASSERT_MESSAGE("Token should be 'ever'", suToken.equals(rtl::OUString::createFromAscii("ever")) == sal_True);
+
+ /* rtl::OUString */ suToken = suTokenStr.getToken( 0, '.', nIndex );
+ CPPUNIT_ASSERT_MESSAGE("Token should be empty", suToken.getLength() == 0);
+
+ CPPUNIT_ASSERT_MESSAGE("index should be negative", nIndex == -1);
+ }
+
+ void getToken_005() {
+ rtl::OUString ab(RTL_CONSTASCII_USTRINGPARAM("ab"));
+ sal_Int32 n = 0;
+ CPPUNIT_ASSERT_MESSAGE(
+ "token should be 'ab'", ab.getToken(0, '-', n) == ab);
+ CPPUNIT_ASSERT_MESSAGE("n should be -1", n == -1);
+ CPPUNIT_ASSERT_MESSAGE(
+ "token should be empty", ab.getToken(0, '-', n).getLength() == 0);
+ }
+
+ CPPUNIT_TEST_SUITE(getToken);
+ CPPUNIT_TEST(getToken_000);
+ CPPUNIT_TEST(getToken_001);
+ CPPUNIT_TEST(getToken_002);
+ CPPUNIT_TEST(getToken_003);
+ CPPUNIT_TEST(getToken_004);
+ CPPUNIT_TEST(getToken_005);
+ CPPUNIT_TEST_SUITE_END();
+}; // class getToken
+
+class convertToString: public CppUnit::TestFixture {
+public:
+ void test();
+
+ CPPUNIT_TEST_SUITE(convertToString);
+ CPPUNIT_TEST(test);
+ CPPUNIT_TEST_SUITE_END();
+};
+
+void convertToString::test() {
+ static sal_Unicode const utf16[] = { 0x0041, 0x00E4, 0x0061 };
+ rtl::OString s;
+ CPPUNIT_ASSERT(
+ rtl::OUString(utf16, sizeof utf16 / sizeof utf16[0]).convertToString(
+ &s, RTL_TEXTENCODING_UTF7,
+ (RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR |
+ RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR)));
+ CPPUNIT_ASSERT_EQUAL(
+ rtl::OString(RTL_CONSTASCII_STRINGPARAM("A+AOQ-a")), s);
+}
+
+// -----------------------------------------------------------------------------
+// - string construction & interning (tests)
+// -----------------------------------------------------------------------------
+class construction : public CppUnit::TestFixture
+{
+public:
+ void construct()
+ {
+#ifdef RTL_INLINE_STRINGS
+ ::rtl::OUString aFoo( RTL_CONSTASCII_USTRINGPARAM("foo") );
+ CPPUNIT_ASSERT_MESSAGE("string contents", aFoo[0] == 'f');
+ CPPUNIT_ASSERT_MESSAGE("string contents", aFoo[1] == 'o');
+ CPPUNIT_ASSERT_MESSAGE("string contents", aFoo[2] == 'o');
+ CPPUNIT_ASSERT_MESSAGE("string length", aFoo.getLength() == 3);
+
+ ::rtl::OUString aBaa( RTL_CONSTASCII_USTRINGPARAM("this is a very long string with a lot of long things inside it and it goes on and on and on forever etc.") );
+ CPPUNIT_ASSERT_MESSAGE("string length", aBaa.getLength() == 104);
+ // Dig at the internals ... FIXME: should we have the bit-flag defines public ?
+ CPPUNIT_ASSERT_MESSAGE("string static flags", (aBaa.pData->refCount & 1<<30) != 0);
+#endif
+ }
+
+ void intern()
+ {
+ // The empty string is 'static' a special case ...
+ rtl::OUString aEmpty = rtl::OUString().intern();
+ rtl::OUString aEmpty2 = rtl::OUString::intern( RTL_CONSTASCII_USTRINGPARAM( "" ) );
+
+ ::rtl::OUString aFoo( RTL_CONSTASCII_USTRINGPARAM("foo") );
+ ::rtl::OUString aFooIntern = aFoo.intern();
+ CPPUNIT_ASSERT_MESSAGE("string contents", aFooIntern.equalsAscii("foo"));
+ CPPUNIT_ASSERT_MESSAGE("string length", aFooIntern.getLength() == 3);
+ // We have to dup due to no atomic 'intern' bit-set operation
+ CPPUNIT_ASSERT_MESSAGE("intern dups", aFoo.pData != aFooIntern.pData);
+
+ // Test interning lots of things
+ int i;
+ static const int nSequence = 4096;
+ rtl::OUString *pStrs;
+ sal_uIntPtr *pValues;
+
+ pStrs = new rtl::OUString[nSequence];
+ pValues = new sal_uIntPtr[nSequence];
+ for (i = 0; i < nSequence; i++)
+ {
+ pStrs[i] = rtl::OUString::valueOf( sqrt( static_cast<double>(i) ) ).intern();
+ pValues[i] = reinterpret_cast<sal_uIntPtr>( pStrs[i].pData );
+ }
+ for (i = 0; i < nSequence; i++)
+ {
+ rtl::OUString aNew = rtl::OUString::valueOf( sqrt( static_cast<double>(i) ) ).intern();
+ CPPUNIT_ASSERT_MESSAGE("double intern failed",
+ aNew.pData == pStrs[i].pData);
+ }
+
+ // Free strings to check for leaks
+ for (i = 0; i < nSequence; i++)
+ {
+ // Overwrite - hopefully this re-uses the memory
+ pStrs[i] = rtl::OUString();
+ pStrs[i] = rtl::OUString::valueOf( sqrt( static_cast<double>(i) ) );
+ }
+
+ for (i = 0; i < nSequence; i++)
+ {
+ rtl::OUString aIntern;
+ sal_uIntPtr nValue;
+ aIntern = rtl::OUString::valueOf( sqrt( static_cast<double>(i) ) ).intern();
+
+ nValue = reinterpret_cast<sal_uIntPtr>( aIntern.pData );
+ // This may not be 100% reliable: memory may
+ // have been re-used, but it's worth checking.
+ CPPUNIT_ASSERT_MESSAGE("intern leaking", nValue != pValues[i]);
+ }
+ delete [] pValues;
+ delete [] pStrs;
+ }
+
+ CPPUNIT_TEST_SUITE(construction);
+ CPPUNIT_TEST(construct);
+ CPPUNIT_TEST(intern);
+ CPPUNIT_TEST_SUITE_END();
+};
+
+class indexOfAscii: public CppUnit::TestFixture {
+public:
+ void test();
+
+ CPPUNIT_TEST_SUITE(indexOfAscii);
+ CPPUNIT_TEST(test);
+ CPPUNIT_TEST_SUITE_END();
+};
+
+void indexOfAscii::test() {
+ CPPUNIT_ASSERT_EQUAL(
+ sal_Int32(-1),
+ rtl::OUString().indexOfAsciiL(RTL_CONSTASCII_STRINGPARAM("")));
+ CPPUNIT_ASSERT_EQUAL(
+ sal_Int32(-1),
+ rtl::OUString().lastIndexOfAsciiL(RTL_CONSTASCII_STRINGPARAM("")));
+ CPPUNIT_ASSERT_EQUAL(
+ sal_Int32(0),
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("foo")).indexOfAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("foo")));
+ CPPUNIT_ASSERT_EQUAL(
+ sal_Int32(0),
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("foo")).lastIndexOfAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("foo")));
+ CPPUNIT_ASSERT_EQUAL(
+ sal_Int32(2),
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("fofoobar")).indexOfAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("foo")));
+ CPPUNIT_ASSERT_EQUAL(
+ sal_Int32(3),
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("foofoofob")).
+ lastIndexOfAsciiL(RTL_CONSTASCII_STRINGPARAM("foo")));
+ CPPUNIT_ASSERT_EQUAL(
+ sal_Int32(3),
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("foofoobar")).indexOfAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("foo"), 1));
+}
+
+class endsWith: public CppUnit::TestFixture {
+public:
+ void test();
+
+ CPPUNIT_TEST_SUITE(endsWith);
+ CPPUNIT_TEST(test);
+ CPPUNIT_TEST_SUITE_END();
+};
+
+void endsWith::test() {
+ CPPUNIT_ASSERT_EQUAL(
+ true,
+ rtl::OUString().endsWithAsciiL(RTL_CONSTASCII_STRINGPARAM("")));
+ CPPUNIT_ASSERT_EQUAL(
+ false,
+ rtl::OUString().endsWithAsciiL(RTL_CONSTASCII_STRINGPARAM("foo")));
+ CPPUNIT_ASSERT_EQUAL(
+ true,
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("bar")).endsWithAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("bar")));
+ CPPUNIT_ASSERT_EQUAL(
+ true,
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("foobar")).endsWithAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("bar")));
+ CPPUNIT_ASSERT_EQUAL(
+ false,
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FOOBAR")).endsWithAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("bar")));
+}
+
+class createFromCodePoints: public CppUnit::TestFixture {
+public:
+ void test();
+
+ CPPUNIT_TEST_SUITE(createFromCodePoints);
+ CPPUNIT_TEST(test);
+ CPPUNIT_TEST_SUITE_END();
+};
+
+void createFromCodePoints::test() {
+ CPPUNIT_ASSERT_EQUAL(
+ sal_Int32(0),
+ rtl::OUString(static_cast< sal_uInt32 const * >(NULL), 0).getLength());
+ static sal_uInt32 const cp[] = { 0, 0xD800, 0xFFFF, 0x10000, 0x10FFFF };
+ rtl::OUString s(cp, sizeof cp / sizeof (sal_uInt32));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(7), s.getLength());
+ CPPUNIT_ASSERT_EQUAL(sal_Unicode(0), s[0]);
+ CPPUNIT_ASSERT_EQUAL(sal_Unicode(0xD800), s[1]);
+ CPPUNIT_ASSERT_EQUAL(sal_Unicode(0xFFFF), s[2]);
+ CPPUNIT_ASSERT_EQUAL(sal_Unicode(0xD800), s[3]);
+ CPPUNIT_ASSERT_EQUAL(sal_Unicode(0xDC00), s[4]);
+ CPPUNIT_ASSERT_EQUAL(sal_Unicode(0xDBFF), s[5]);
+ CPPUNIT_ASSERT_EQUAL(sal_Unicode(0xDFFF), s[6]);
+}
+
+class iterateCodePoints: public CppUnit::TestFixture {
+public:
+ void testNotWellFormed();
+
+ CPPUNIT_TEST_SUITE(iterateCodePoints);
+ CPPUNIT_TEST(testNotWellFormed);
+ CPPUNIT_TEST_SUITE_END();
+};
+
+void iterateCodePoints::testNotWellFormed() {
+ static sal_Unicode const utf16[] =
+ { 0xD800, 0xDC00, 0x0041, 0xDBFF, 0xDFFF, 0xDDEF, 0xD9AB };
+ rtl::OUString s(utf16, sizeof utf16 / sizeof (sal_Unicode));
+ sal_Int32 i = 0;
+ CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x10000), s.iterateCodePoints(&i));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(2), i);
+ CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x0041), s.iterateCodePoints(&i));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(3), i);
+ CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x10FFFF), s.iterateCodePoints(&i));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(5), i);
+ CPPUNIT_ASSERT_EQUAL(sal_uInt32(0xDDEF), s.iterateCodePoints(&i));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(6), i);
+ CPPUNIT_ASSERT_EQUAL(sal_uInt32(0xD9AB), s.iterateCodePoints(&i));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(7), i);
+ CPPUNIT_ASSERT_EQUAL(sal_uInt32(0xD9AB), s.iterateCodePoints(&i, -1));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(6), i);
+ CPPUNIT_ASSERT_EQUAL(sal_uInt32(0xDDEF), s.iterateCodePoints(&i, -1));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(5), i);
+ CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x10FFFF), s.iterateCodePoints(&i, -1));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(3), i);
+ CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x0041), s.iterateCodePoints(&i, -1));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(2), i);
+ CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x10000), s.iterateCodePoints(&i, -1));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), i);
+ i = 1;
+ CPPUNIT_ASSERT_EQUAL(sal_uInt32(0xDC00), s.iterateCodePoints(&i, 2));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(3), i);
+ i = 4;
+ CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x10000), s.iterateCodePoints(&i, -3));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), i);
+}
+
+class convertFromString: public CppUnit::TestFixture {
+public:
+ void test();
+
+ CPPUNIT_TEST_SUITE(createFromCodePoints);
+ CPPUNIT_TEST(test);
+ CPPUNIT_TEST_SUITE_END();
+};
+
+void convertFromString::test() {
+ rtl::OUString t;
+ CPPUNIT_ASSERT(
+ !rtl_convertStringToUString(
+ &t.pData, RTL_CONSTASCII_STRINGPARAM("\x80"), RTL_TEXTENCODING_UTF8,
+ (RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR |
+ RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR |
+ RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR)));
+ CPPUNIT_ASSERT(
+ !rtl_convertStringToUString(
+ &t.pData, RTL_CONSTASCII_STRINGPARAM("\xC0"), RTL_TEXTENCODING_UTF8,
+ (RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR |
+ RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR |
+ RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR)));
+ CPPUNIT_ASSERT(
+ !rtl_convertStringToUString(
+ &t.pData, RTL_CONSTASCII_STRINGPARAM("\xFF"), RTL_TEXTENCODING_UTF8,
+ (RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR |
+ RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR |
+ RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR)));
+ CPPUNIT_ASSERT(
+ rtl_convertStringToUString(
+ &t.pData, RTL_CONSTASCII_STRINGPARAM("abc"), RTL_TEXTENCODING_UTF8,
+ (RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR |
+ RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR |
+ RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR)));
+ CPPUNIT_ASSERT(t.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("abc")));
+}
+
+// -----------------------------------------------------------------------------
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_OUString::valueOf, "rtl_OUString");
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_OUString::toInt, "rtl_OUString");
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_OUString::toDouble, "rtl_OUString");
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_OUString::toFloat, "rtl_OUString");
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_OUString::lastIndexOf, "rtl_OUString");
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_OUString::getToken, "rtl_OUString");
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(
+ rtl_OUString::convertToString, "rtl_OUString");
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_OUString::construction, "rtl_OUString");
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(
+ rtl_OUString::indexOfAscii, "rtl_OUString");
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_OUString::endsWith, "rtl_OUString");
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(
+ rtl_OUString::createFromCodePoints, "rtl_OUString");
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(
+ rtl_OUString::iterateCodePoints, "rtl_OUString");
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(
+ rtl_OUString::convertFromString, "rtl_OUString");
+
+} // namespace rtl_OUString
+
+
+// -----------------------------------------------------------------------------
+
+// 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/oustring/rtl_ustr.cxx b/sal/qa/rtl/oustring/rtl_ustr.cxx
new file mode 100644
index 000000000000..fd207ef0778c
--- /dev/null
+++ b/sal/qa/rtl/oustring/rtl_ustr.cxx
@@ -0,0 +1,1424 @@
+/*************************************************************************
+ *
+ * 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 <testshl/simpleheader.hxx>
+
+/** print a UNI_CODE file name.
+*/
+inline void printOUString( ::rtl::OUString const & _suStr )
+{
+ rtl::OString aString;
+
+ t_print( "OUString: " );
+ aString = ::rtl::OUStringToOString( _suStr, RTL_TEXTENCODING_ASCII_US );
+ t_print( "%s\n", aString.getStr( ) );
+}
+
+
+namespace rtl_ustr
+{
+
+ class compare : public CppUnit::TestFixture
+ {
+ public:
+
+
+ void compare_000()
+ {
+ rtl_ustr_compare( NULL, NULL);
+ // should not GPF
+ }
+
+ void compare_000_1()
+ {
+ rtl::OUString aStr1 = rtl::OUString::createFromAscii("Line must be equal.");
+ rtl_ustr_compare( aStr1.getStr(), NULL);
+ // should not GPF
+ }
+ void compare_001()
+ {
+ rtl::OUString aStr1;
+ rtl::OUString aStr2;
+
+ sal_Int32 nValue = rtl_ustr_compare( aStr1.getStr(), aStr2.getStr());
+ CPPUNIT_ASSERT_MESSAGE("compare failed, strings are equal.", nValue == 0);
+ }
+
+ void compare_002()
+ {
+ rtl::OUString aStr1 = rtl::OUString::createFromAscii("Line must be equal.");
+ rtl::OUString aStr2 = rtl::OUString::createFromAscii("Line must be equal.");
+
+ sal_Int32 nValue = rtl_ustr_compare( aStr1.getStr(), aStr2.getStr());
+ CPPUNIT_ASSERT_MESSAGE("compare failed, strings are equal.", nValue == 0);
+ }
+
+ void compare_003()
+ {
+ rtl::OUString aStr1 = rtl::OUString::createFromAscii("Line must differ.");
+ rtl::OUString aStr2 = rtl::OUString::createFromAscii("Line foo bar, ok, differ.");
+
+ sal_Int32 nValue = rtl_ustr_compare( aStr1.getStr(), aStr2.getStr());
+ CPPUNIT_ASSERT_MESSAGE("compare failed, strings differ.", nValue != 0);
+ }
+
+ // 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(compare);
+ CPPUNIT_TEST(compare_000);
+ CPPUNIT_TEST(compare_000_1);
+ CPPUNIT_TEST(compare_001);
+ CPPUNIT_TEST(compare_002);
+ CPPUNIT_TEST(compare_003);
+ CPPUNIT_TEST_SUITE_END();
+}; // class compare
+
+
+ class compareIgnoreAsciiCase : public CppUnit::TestFixture
+ {
+ public:
+
+ void compare_000()
+ {
+ rtl_ustr_compareIgnoreAsciiCase( NULL, NULL);
+ }
+
+ void compare_000_1()
+ {
+ rtl::OUString aStr1 = rtl::OUString::createFromAscii("Line must be equal.");
+ rtl_ustr_compareIgnoreAsciiCase( aStr1.getStr(), NULL);
+ }
+ void compare_001()
+ {
+ rtl::OUString aStr1;
+ rtl::OUString aStr2;
+
+ sal_Int32 nValue = rtl_ustr_compareIgnoreAsciiCase( aStr1.getStr(), aStr2.getStr());
+ CPPUNIT_ASSERT_MESSAGE("compare failed, strings are equal.", nValue == 0);
+ }
+
+ void compare_002()
+ {
+ rtl::OUString aStr1 = rtl::OUString::createFromAscii("Line must be equal.");
+ rtl::OUString aStr2 = rtl::OUString::createFromAscii("Line must be equal.");
+
+ sal_Int32 nValue = rtl_ustr_compareIgnoreAsciiCase( aStr1.getStr(), aStr2.getStr());
+ CPPUNIT_ASSERT_MESSAGE("compare failed, strings are equal.", nValue == 0);
+ }
+
+ void compare_002_1()
+ {
+ rtl::OUString aStr1 = rtl::OUString::createFromAscii("Line must be equal.");
+ rtl::OUString aStr2 = rtl::OUString::createFromAscii("LINE MUST BE EQUAL.");
+
+ sal_Int32 nValue = rtl_ustr_compareIgnoreAsciiCase( aStr1.getStr(), aStr2.getStr());
+ CPPUNIT_ASSERT_MESSAGE("compare failed, strings are equal (if case insensitve).", nValue == 0);
+ }
+
+ void compare_003()
+ {
+ rtl::OUString aStr1 = rtl::OUString::createFromAscii("Line must differ.");
+ rtl::OUString aStr2 = rtl::OUString::createFromAscii("Line foo bar, ok, differ.");
+
+ sal_Int32 nValue = rtl_ustr_compareIgnoreAsciiCase( aStr1.getStr(), aStr2.getStr());
+ CPPUNIT_ASSERT_MESSAGE("compare failed, strings differ.", nValue != 0);
+ }
+
+ // 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(compareIgnoreAsciiCase);
+ CPPUNIT_TEST(compare_000);
+ CPPUNIT_TEST(compare_000_1);
+ CPPUNIT_TEST(compare_001);
+ CPPUNIT_TEST(compare_002);
+ CPPUNIT_TEST(compare_002_1);
+ CPPUNIT_TEST(compare_003);
+ CPPUNIT_TEST_SUITE_END();
+ }; // class compareIgnoreAsciiCase
+
+// -----------------------------------------------------------------------------
+
+ class shortenedCompareIgnoreAsciiCase_WithLength : public CppUnit::TestFixture
+ {
+ public:
+
+ void compare_000()
+ {
+ rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( NULL, 0, NULL, 0, 0);
+ }
+
+ void compare_000_1()
+ {
+ rtl::OUString aStr1 = rtl::OUString::createFromAscii("Line must be equal.");
+ rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( aStr1.getStr(), aStr1.getLength(), NULL, 0, 1);
+ }
+ void compare_001()
+ {
+ rtl::OUString aStr1;
+ rtl::OUString aStr2;
+
+ sal_Int32 nValue = rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( aStr1.getStr(), aStr1.getLength(), aStr2.getStr(), aStr2.getLength(), aStr1.getLength());
+ CPPUNIT_ASSERT_MESSAGE("compare failed, strings are equal.", nValue == 0);
+ }
+
+ void compare_002()
+ {
+ rtl::OUString aStr1 = rtl::OUString::createFromAscii("Line must be equal.");
+ rtl::OUString aStr2 = rtl::OUString::createFromAscii("Line must be equal.");
+
+ sal_Int32 nValue = rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( aStr1.getStr(), aStr1.getLength(),
+ aStr2.getStr(), aStr2.getLength(),
+ aStr1.getLength());
+ CPPUNIT_ASSERT_MESSAGE("compare failed, strings are equal.", nValue == 0);
+ }
+
+ void compare_002_1()
+ {
+ rtl::OUString aStr1 = rtl::OUString::createFromAscii("Line must be equal.");
+ rtl::OUString aStr2 = rtl::OUString::createFromAscii("LINE MUST BE EQUAL.");
+
+ sal_Int32 nValue = rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( aStr1.getStr(), aStr1.getLength(),
+ aStr2.getStr(), aStr2.getLength(),
+ aStr1.getLength());
+ CPPUNIT_ASSERT_MESSAGE("compare failed, strings are equal (if case insensitve).", nValue == 0);
+ }
+
+ void compare_003()
+ {
+ rtl::OUString aStr1 = rtl::OUString::createFromAscii("Line must differ.");
+ rtl::OUString aStr2 = rtl::OUString::createFromAscii("Line foo bar, ok, differ.");
+
+ sal_Int32 nValue = rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( aStr1.getStr(), aStr1.getLength(),
+ aStr2.getStr(), aStr2.getLength(),
+ 5);
+ CPPUNIT_ASSERT_MESSAGE("compare failed, strings are equal first 5 characters.", nValue == 0);
+ }
+
+ void compare_004()
+ {
+ rtl::OUString aStr1 = rtl::OUString::createFromAscii("Line must differ.");
+ rtl::OUString aStr2 = rtl::OUString::createFromAscii("Line foo bar, ok, differ.");
+
+ sal_Int32 nValue = rtl_ustr_shortenedCompareIgnoreAsciiCase_WithLength( aStr1.getStr(), aStr1.getLength(),
+ aStr2.getStr(), aStr2.getLength(),
+ aStr1.getLength());
+ CPPUNIT_ASSERT_MESSAGE("compare failed, strings differ.", nValue != 0);
+ }
+
+ // 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(shortenedCompareIgnoreAsciiCase_WithLength);
+ CPPUNIT_TEST(compare_000);
+ CPPUNIT_TEST(compare_000_1);
+ CPPUNIT_TEST(compare_001);
+ CPPUNIT_TEST(compare_002);
+ CPPUNIT_TEST(compare_002_1);
+ CPPUNIT_TEST(compare_003);
+ CPPUNIT_TEST(compare_004);
+ CPPUNIT_TEST_SUITE_END();
+}; // class compare
+
+
+// // -----------------------------------------------------------------------------
+//
+// class hashCode : public CppUnit::TestFixture
+// {
+// public:
+//
+// void hashCode_000()
+// {
+// sal_Int32 nHashCode = rtl_ustr_hashCode( NULL );
+// volatile int dummy = 0;
+// }
+//
+// void hashCode_001()
+// {
+// rtl::OString aStr1 = "Line for a hashCode.";
+// sal_Int32 nHashCode = rtl_ustr_hashCode( aStr1.getStr() );
+// t_print("hashcode: %d\n", nHashCode);
+// // CPPUNIT_ASSERT_MESSAGE("failed.", nValue == 0);
+// }
+//
+// void hashCode_002()
+// {
+// rtl::OString aStr1 = "Line for a hashCode.";
+// sal_Int32 nHashCode1 = rtl_ustr_hashCode( aStr1.getStr() );
+//
+// rtl::OString aStr2 = "Line for a hashCode.";
+// sal_Int32 nHashCode2 = rtl_ustr_hashCode( aStr2.getStr() );
+//
+// CPPUNIT_ASSERT_MESSAGE("hashcodes must be equal.", nHashCode1 == nHashCode2 );
+// }
+//
+// void hashCode_003()
+// {
+// rtl::OString aStr1 = "Line for a hashCode.";
+// sal_Int32 nHashCode1 = rtl_ustr_hashCode( aStr1.getStr() );
+//
+// rtl::OString aStr2 = "Line for an other hashcode.";
+// sal_Int32 nHashCode2 = rtl_ustr_hashCode( aStr2.getStr() );
+//
+// CPPUNIT_ASSERT_MESSAGE("hashcodes must differ.", nHashCode1 != nHashCode2 );
+// }
+//
+// // 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(hashCode);
+// CPPUNIT_TEST(hashCode_000);
+// CPPUNIT_TEST(hashCode_001);
+// CPPUNIT_TEST(hashCode_002);
+// CPPUNIT_TEST(hashCode_003);
+// CPPUNIT_TEST_SUITE_END();
+// }; // class compare
+//
+//
+// // -----------------------------------------------------------------------------
+//
+ class indexOfChar : public CppUnit::TestFixture
+ {
+ public:
+
+ void indexOfChar_000()
+ {
+ rtl_ustr_indexOfChar( NULL, 0 );
+ }
+
+ void indexOfChar_001()
+ {
+ rtl::OUString aStr1 = rtl::OUString::createFromAscii("Line for a indexOfChar.");
+
+ sal_Int32 nIndex = rtl_ustr_indexOfChar( aStr1.getStr(), 'L' );
+ CPPUNIT_ASSERT_MESSAGE("index is wrong.", nIndex == 0);
+
+ /* sal_Int32 */ nIndex = rtl_ustr_indexOfChar( aStr1.getStr(), 'i' );
+ CPPUNIT_ASSERT_MESSAGE("index is wrong.", nIndex == 1);
+
+ /* sal_Int32 */ nIndex = rtl_ustr_indexOfChar( aStr1.getStr(), 'n' );
+ CPPUNIT_ASSERT_MESSAGE("index is wrong.", nIndex == 2);
+
+ /* sal_Int32 */ nIndex = rtl_ustr_indexOfChar( aStr1.getStr(), 'e' );
+ CPPUNIT_ASSERT_MESSAGE("index is wrong.", nIndex == 3);
+ }
+
+ void indexOfChar_002()
+ {
+ rtl::OUString aStr1 = rtl::OUString::createFromAscii("Line for a indexOfChar.");
+ sal_Int32 nIndex = rtl_ustr_indexOfChar( aStr1.getStr(), 'y' );
+
+ CPPUNIT_ASSERT_MESSAGE("index is wrong.", nIndex == -1 );
+ }
+
+ // 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(indexOfChar);
+ CPPUNIT_TEST(indexOfChar_000);
+ CPPUNIT_TEST(indexOfChar_001);
+ CPPUNIT_TEST(indexOfChar_002);
+ CPPUNIT_TEST_SUITE_END();
+ }; // class indexOfChar
+
+// // -----------------------------------------------------------------------------
+ class lastIndexOfChar : public CppUnit::TestFixture
+ {
+ public:
+
+ void lastIndexOfChar_000()
+ {
+ rtl_ustr_lastIndexOfChar( NULL, 0 );
+ }
+
+ void lastIndexOfChar_001()
+ {
+ rtl::OUString aStr1 = rtl::OUString::createFromAscii("Line for a lastIndexOfChar.");
+
+ sal_Int32 nIndex = rtl_ustr_lastIndexOfChar( aStr1.getStr(), 'C' );
+ CPPUNIT_ASSERT_MESSAGE("index is wrong.", nIndex == 22);
+
+ /* sal_Int32 */ nIndex = rtl_ustr_lastIndexOfChar( aStr1.getStr(), 'h' );
+ CPPUNIT_ASSERT_MESSAGE("index is wrong.", nIndex == 23);
+
+ /* sal_Int32 */ nIndex = rtl_ustr_lastIndexOfChar( aStr1.getStr(), 'a' );
+ CPPUNIT_ASSERT_MESSAGE("index is wrong.", nIndex == 24);
+
+ /* sal_Int32 */ nIndex = rtl_ustr_lastIndexOfChar( aStr1.getStr(), 'r' );
+ CPPUNIT_ASSERT_MESSAGE("index is wrong.", nIndex == 25);
+ }
+
+ void lastIndexOfChar_002()
+ {
+ rtl::OUString aStr1 = rtl::OUString::createFromAscii("Line for a lastIndexOfChar.");
+ sal_Int32 nIndex = rtl_ustr_lastIndexOfChar( aStr1.getStr(), 'y' );
+
+ CPPUNIT_ASSERT_MESSAGE("index is wrong.", nIndex == -1 );
+ }
+
+ // 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(lastIndexOfChar);
+ CPPUNIT_TEST(lastIndexOfChar_000);
+ CPPUNIT_TEST(lastIndexOfChar_001);
+ CPPUNIT_TEST(lastIndexOfChar_002);
+ CPPUNIT_TEST_SUITE_END();
+ }; // class lastIndexOfChar
+
+
+// -----------------------------------------------------------------------------
+
+ class indexOfStr : public CppUnit::TestFixture
+ {
+ public:
+
+ void indexOfStr_000()
+ {
+ rtl_ustr_indexOfStr( NULL, 0 );
+ }
+
+ void indexOfStr_000_1()
+ {
+ rtl::OUString aStr1 = rtl::OUString::createFromAscii("Line for a indexOfStr.");
+ rtl_ustr_indexOfStr( aStr1.getStr(), 0 );
+ }
+
+ void indexOfStr_001()
+ {
+ rtl::OUString aStr1 = rtl::OUString::createFromAscii("Line for a indexOfStr.");
+
+ rtl::OUString suSearch = rtl::OUString::createFromAscii("Line");
+ sal_Int32 nIndex = rtl_ustr_indexOfStr( aStr1.getStr(), suSearch );
+ CPPUNIT_ASSERT_MESSAGE("index is wrong.", nIndex == 0);
+
+ /* rtl::OUString */ suSearch = rtl::OUString::createFromAscii("for");
+ /* sal_Int32 */ nIndex = rtl_ustr_indexOfStr( aStr1.getStr(), suSearch );
+ CPPUNIT_ASSERT_MESSAGE("index is wrong.", nIndex == 5);
+
+ /* rtl::OUString */ suSearch = rtl::OUString::createFromAscii("a");
+ /* sal_Int32 */ nIndex = rtl_ustr_indexOfStr( aStr1.getStr(), suSearch );
+ CPPUNIT_ASSERT_MESSAGE("index is wrong.", nIndex == 9);
+
+ /* rtl::OUString */ suSearch = rtl::OUString::createFromAscii("a index");
+ /* sal_Int32 */ nIndex = rtl_ustr_indexOfStr( aStr1.getStr(), suSearch );
+ CPPUNIT_ASSERT_MESSAGE("index is wrong.", nIndex ==9);
+ }
+
+ void indexOfStr_002()
+ {
+ rtl::OUString aStr1 = rtl::OUString::createFromAscii("Line for a indexOfStr.");
+ rtl::OUString suSearch = rtl::OUString::createFromAscii("not exist");
+ sal_Int32 nIndex = rtl_ustr_indexOfStr( aStr1.getStr(), suSearch );
+
+ CPPUNIT_ASSERT_MESSAGE("index is wrong.", nIndex == -1 );
+ }
+
+ // 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(indexOfStr);
+ CPPUNIT_TEST(indexOfStr_000);
+ CPPUNIT_TEST(indexOfStr_001);
+ CPPUNIT_TEST(indexOfStr_002);
+ CPPUNIT_TEST_SUITE_END();
+ }; // class compare
+// -----------------------------------------------------------------------------
+
+
+ class lastIndexOfStr : public CppUnit::TestFixture
+ {
+ public:
+
+ void lastIndexOfStr_000()
+ {
+ rtl_ustr_lastIndexOfStr( NULL, NULL );
+ }
+
+ void lastIndexOfStr_000_1()
+ {
+ rtl::OUString aStr1 = rtl::OUString::createFromAscii("Line for a lastIndexOfStr.");
+ rtl_ustr_lastIndexOfStr( aStr1.getStr(), NULL );
+ }
+
+ void lastIndexOfStr_001()
+ {
+ rtl::OUString aStr1 = rtl::OUString::createFromAscii("Line for a lastIndexOfStr.");
+ rtl::OUString aSearchStr = rtl::OUString::createFromAscii("Index");
+
+ sal_Int32 nIndex = rtl_ustr_lastIndexOfStr( aStr1.getStr(), aSearchStr.getStr() );
+ CPPUNIT_ASSERT_MESSAGE("index is wrong.", nIndex == 15);
+
+ /* rtl::OString */ aSearchStr = rtl::OUString::createFromAscii("Line");
+ /* sal_Int32 */ nIndex = rtl_ustr_lastIndexOfStr( aStr1.getStr(), aSearchStr.getStr() );
+ CPPUNIT_ASSERT_MESSAGE("index is wrong.", nIndex == 0);
+
+ /* rtl::OString */ aSearchStr = rtl::OUString::createFromAscii("");
+ /* sal_Int32 */ nIndex = rtl_ustr_lastIndexOfStr( aStr1.getStr(), aSearchStr.getStr() );
+ CPPUNIT_ASSERT_MESSAGE("index is wrong.", nIndex == -1);
+ }
+
+ void lastIndexOfStr_002()
+ {
+ rtl::OUString aStr1 = rtl::OUString::createFromAscii("Line for a lastIndexOfStr.");
+ rtl::OUString aSearchStr = rtl::OUString::createFromAscii("foo");
+ sal_Int32 nIndex = rtl_ustr_lastIndexOfStr( aStr1.getStr(), aSearchStr.getStr() );
+
+ CPPUNIT_ASSERT_MESSAGE("index is wrong.", nIndex == -1 );
+ }
+
+ void lastIndexOfStr_003()
+ {
+ rtl::OUString aStr1 = rtl::OUString::createFromAscii("Line for a lastIndexOfStr.");
+ rtl::OUString aSearchStr = rtl::OUString::createFromAscii("O");
+ sal_Int32 nIndex = rtl_ustr_lastIndexOfStr( aStr1.getStr(), aSearchStr.getStr() );
+
+ CPPUNIT_ASSERT_MESSAGE("index is wrong.", nIndex == 20 );
+ }
+
+ // 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(lastIndexOfStr);
+ CPPUNIT_TEST(lastIndexOfStr_000);
+ CPPUNIT_TEST(lastIndexOfStr_001);
+ CPPUNIT_TEST(lastIndexOfStr_002);
+ CPPUNIT_TEST(lastIndexOfStr_003);
+ CPPUNIT_TEST_SUITE_END();
+ }; // class lastIndexOfStr
+
+// -----------------------------------------------------------------------------
+
+ class replaceChar : public CppUnit::TestFixture
+ {
+ public:
+
+ void replaceChar_000()
+ {
+ rtl_ustr_replaceChar( NULL, 0, 0 );
+ }
+
+ void replaceChar_001()
+ {
+ rtl::OUString aStr1 = rtl::OUString::createFromAscii("replace char.");
+ rtl::OUString aShouldStr1 = rtl::OUString::createFromAscii("ruplacu char.");
+
+ sal_uInt32 nLength = aStr1.getLength() * sizeof(sal_Unicode);
+ sal_Unicode* pStr = (sal_Unicode*) malloc( nLength + sizeof(sal_Unicode)); // length + 1 (null terminator)
+ CPPUNIT_ASSERT_MESSAGE("can't get memory for test", pStr != NULL);
+ memset(pStr, 0, nLength + sizeof(sal_Unicode));
+ memcpy(pStr, aStr1.getStr(), nLength);
+
+ rtl_ustr_replaceChar( pStr, 'e', 'u' );
+ rtl::OUString suStr(pStr, aStr1.getLength());
+
+ CPPUNIT_ASSERT_MESSAGE("replace failed", aShouldStr1.equals(suStr) == sal_True);
+ free(pStr);
+ }
+
+ // 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(replaceChar);
+ CPPUNIT_TEST(replaceChar_000);
+ CPPUNIT_TEST(replaceChar_001);
+ CPPUNIT_TEST_SUITE_END();
+ }; // class replaceChar
+
+// -----------------------------------------------------------------------------
+
+ class replaceChar_WithLength : public CppUnit::TestFixture
+ {
+ public:
+
+ void replaceChar_WithLength_000()
+ {
+ rtl_ustr_replaceChar_WithLength( NULL, 0, 0, 0 );
+ }
+
+ void replaceChar_WithLength_000_1()
+ {
+ rtl_ustr_replaceChar_WithLength( NULL, 1, 0, 0 );
+ }
+ void replaceChar_WithLength_001()
+ {
+ rtl::OUString aStr1 = rtl::OUString::createFromAscii("replace char.");
+ rtl::OUString aShouldStr1 = rtl::OUString::createFromAscii("ruplace char.");
+
+ sal_uInt32 nLength = aStr1.getLength() * sizeof(sal_Unicode);
+ sal_Unicode* pStr = (sal_Unicode*) malloc(nLength);
+ CPPUNIT_ASSERT_MESSAGE("can't get memory for test", pStr != NULL);
+ memcpy(pStr, aStr1.getStr(), nLength);
+
+ rtl_ustr_replaceChar_WithLength( pStr, 6, 'e', 'u' );
+ rtl::OUString suStr(pStr, aStr1.getLength());
+
+ CPPUNIT_ASSERT_MESSAGE("replace failed", aShouldStr1.equals(suStr) == sal_True);
+ free(pStr);
+ }
+
+ void replaceChar_WithLength_002()
+ {
+ rtl::OUString aStr1 = rtl::OUString::createFromAscii("eeeeeeeeeeeee");
+ rtl::OUString aShouldStr1 = rtl::OUString::createFromAscii("uuuuuueeeeeee");
+
+ sal_uInt32 nLength = aStr1.getLength() * sizeof(sal_Unicode);
+ sal_Unicode* pStr = (sal_Unicode*) malloc(nLength); // no null terminator is need
+ CPPUNIT_ASSERT_MESSAGE("can't get memory for test", pStr != NULL);
+ memcpy(pStr, aStr1.getStr(), nLength);
+
+ rtl_ustr_replaceChar_WithLength( pStr, 6, 'e', 'u' );
+ rtl::OUString suStr(pStr, aStr1.getLength());
+
+ CPPUNIT_ASSERT_MESSAGE("replace failed", aShouldStr1.equals(suStr) == sal_True);
+ free(pStr);
+ }
+
+ // 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(replaceChar_WithLength);
+ CPPUNIT_TEST(replaceChar_WithLength_000);
+ CPPUNIT_TEST(replaceChar_WithLength_000_1);
+ CPPUNIT_TEST(replaceChar_WithLength_001);
+ CPPUNIT_TEST(replaceChar_WithLength_002);
+ CPPUNIT_TEST_SUITE_END();
+ }; // class replaceChar
+
+
+// -----------------------------------------------------------------------------
+
+ class toAsciiLowerCase : public CppUnit::TestFixture
+ {
+ public:
+
+ void toAsciiLowerCase_000()
+ {
+ rtl_ustr_toAsciiLowerCase( NULL );
+ }
+
+ void toAsciiLowerCase_001()
+ {
+ rtl::OUString aStr1 = rtl::OUString::createFromAscii("CHANGE THIS TO ASCII LOWER CASE.");
+ rtl::OUString aShouldStr1 = rtl::OUString::createFromAscii("change this to ascii lower case.");
+
+ sal_uInt32 nLength = aStr1.getLength() * sizeof(sal_Unicode);
+ sal_Unicode* pStr = (sal_Unicode*) malloc(nLength + sizeof(sal_Unicode) ); // we need to add '\0' so one more
+ CPPUNIT_ASSERT_MESSAGE("can't get memory for test", pStr != NULL);
+ memset(pStr, 0, nLength + sizeof(sal_Unicode)); // empty the sal_Unicode array
+ memcpy(pStr, aStr1.getStr(), nLength);
+
+ rtl_ustr_toAsciiLowerCase( pStr );
+ rtl::OUString suStr(pStr, aStr1.getLength());
+
+ CPPUNIT_ASSERT_MESSAGE("failed", aShouldStr1.equals(suStr) == sal_True);
+ free(pStr);
+ }
+
+ // 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(toAsciiLowerCase);
+ CPPUNIT_TEST(toAsciiLowerCase_000);
+ CPPUNIT_TEST(toAsciiLowerCase_001);
+ CPPUNIT_TEST_SUITE_END();
+ }; // class replaceChar
+
+
+ class toAsciiLowerCase_WithLength : public CppUnit::TestFixture
+ {
+ public:
+
+ void toAsciiLowerCase_WithLength_000()
+ {
+ rtl_ustr_toAsciiLowerCase_WithLength( NULL, 0 );
+ }
+
+ void toAsciiLowerCase_WithLength_001()
+ {
+ rtl::OUString aStr1 = rtl::OUString::createFromAscii("CHANGE THIS TO ASCII LOWER CASE.");
+ rtl::OUString aShouldStr1 = rtl::OUString::createFromAscii("change thiS TO ASCII LOWER CASE.");
+
+ sal_uInt32 nLength = aStr1.getLength() * sizeof(sal_Unicode);
+ sal_Unicode* pStr = (sal_Unicode*) malloc(nLength);
+ CPPUNIT_ASSERT_MESSAGE("can't get memory for test", pStr != NULL);
+ memcpy(pStr, aStr1.getStr(), nLength);
+
+ rtl_ustr_toAsciiLowerCase_WithLength( pStr, 10 );
+
+ rtl::OUString suStr(pStr, aStr1.getLength());
+ sal_Bool bResult = aShouldStr1.equals(suStr);
+
+ printOUString(suStr);
+ t_print("Result length: %d\n", suStr.getLength() );
+ t_print("Result: %d\n", bResult);
+
+ CPPUNIT_ASSERT_MESSAGE("failed", bResult == sal_True);
+ free(pStr);
+ }
+
+ // 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(toAsciiLowerCase_WithLength);
+ CPPUNIT_TEST(toAsciiLowerCase_WithLength_000);
+ CPPUNIT_TEST(toAsciiLowerCase_WithLength_001);
+ CPPUNIT_TEST_SUITE_END();
+ }; // class replaceChar
+
+// -----------------------------------------------------------------------------
+
+ class toAsciiUpperCase : public CppUnit::TestFixture
+ {
+ public:
+
+ void toAsciiUpperCase_000()
+ {
+ rtl_ustr_toAsciiUpperCase( NULL );
+ }
+
+ void toAsciiUpperCase_001()
+ {
+ rtl::OUString aStr1 = rtl::OUString::createFromAscii("change this to ascii upper case.");
+ rtl::OUString aShouldStr1 = rtl::OUString::createFromAscii("CHANGE THIS TO ASCII UPPER CASE.");
+
+ sal_uInt32 nLength = aStr1.getLength() * sizeof(sal_Unicode);
+ sal_Unicode* pStr = (sal_Unicode*) malloc(nLength + sizeof(sal_Unicode)); // length + null terminator
+ CPPUNIT_ASSERT_MESSAGE("can't get memory for test", pStr != NULL);
+ memset(pStr, 0, nLength + sizeof(sal_Unicode));
+ memcpy(pStr, aStr1.getStr(), nLength);
+
+ rtl_ustr_toAsciiUpperCase( pStr );
+ rtl::OUString suStr(pStr, aStr1.getLength());
+
+ CPPUNIT_ASSERT_MESSAGE("failed", aShouldStr1.equals(suStr) == sal_True);
+ free(pStr);
+ }
+
+ // 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(toAsciiUpperCase);
+ CPPUNIT_TEST(toAsciiUpperCase_000);
+ CPPUNIT_TEST(toAsciiUpperCase_001);
+ CPPUNIT_TEST_SUITE_END();
+ }; // class replaceChar
+
+
+ class toAsciiUpperCase_WithLength : public CppUnit::TestFixture
+ {
+ public:
+
+ void toAsciiUpperCase_WithLength_000()
+ {
+ rtl_ustr_toAsciiUpperCase_WithLength( NULL, 0 );
+ }
+
+ void toAsciiUpperCase_WithLength_001()
+ {
+ rtl::OUString aStr1 = rtl::OUString::createFromAscii("change this to ascii lower case.");
+ rtl::OUString aShouldStr1 = rtl::OUString::createFromAscii("CHANGE THIs to ascii lower case.");
+
+ sal_uInt32 nLength = aStr1.getLength() * sizeof(sal_Unicode);
+ sal_Unicode* pStr = (sal_Unicode*) malloc(nLength);
+ CPPUNIT_ASSERT_MESSAGE("can't get memory for test", pStr != NULL);
+
+ memcpy(pStr, aStr1.getStr(), nLength);
+ rtl_ustr_toAsciiUpperCase_WithLength( pStr, 10 );
+ rtl::OUString suStr(pStr, aStr1.getLength());
+
+ // t_print("Uppercase with length: '%s'\n", aStr1.getStr());
+ CPPUNIT_ASSERT_MESSAGE("failed", aShouldStr1.equals(suStr) == sal_True);
+ free(pStr);
+ }
+
+ // 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(toAsciiUpperCase_WithLength);
+ CPPUNIT_TEST(toAsciiUpperCase_WithLength_000);
+ CPPUNIT_TEST(toAsciiUpperCase_WithLength_001);
+ CPPUNIT_TEST_SUITE_END();
+ }; // class replaceChar
+
+
+ // -----------------------------------------------------------------------------
+
+ class trim_WithLength : public CppUnit::TestFixture
+ {
+ public:
+ void trim_WithLength_000()
+ {
+ rtl_ustr_trim_WithLength(NULL, 0);
+ // should not GPF
+ }
+
+ void trim_WithLength_000_1()
+ {
+ rtl::OUString suStr = rtl::OUString::createFromAscii(" trim this");
+
+ sal_uInt32 nLength = suStr.getLength() * sizeof(sal_Unicode);
+ sal_Unicode *pStr = (sal_Unicode*)malloc(nLength);
+ memcpy(pStr, suStr.getStr(), nLength);
+
+ rtl_ustr_trim_WithLength( pStr, 0 );
+ free(pStr);
+ }
+
+ void trim_WithLength_001()
+ {
+ rtl::OUString suStr = rtl::OUString::createFromAscii(" trim this");
+ sal_uInt32 nLength = suStr.getLength() * sizeof(sal_Unicode);
+ sal_Unicode *pStr = (sal_Unicode*)malloc(nLength);
+ memcpy(pStr, suStr.getStr(), nLength);
+
+ rtl_ustr_trim_WithLength( pStr, 2 );
+
+ CPPUNIT_ASSERT_MESSAGE("string should be empty", rtl::OUString(pStr).getLength() == 0);
+ free(pStr);
+ }
+
+
+ void trim_WithLength_002()
+ {
+ rtl::OUString suStr = rtl::OUString::createFromAscii("trim this");
+
+ sal_uInt32 nLength = suStr.getLength() * sizeof(sal_Unicode);
+ sal_Unicode *pStr = (sal_Unicode*)malloc(nLength);
+ memcpy(pStr, suStr.getStr(), nLength);
+
+ rtl_ustr_trim_WithLength( pStr, 5 );
+
+ CPPUNIT_ASSERT_MESSAGE("string should contain 'trim'", rtl::OUString(pStr).getLength() == 4);
+ free(pStr);
+ }
+
+
+ void trim_WithLength_003()
+ {
+ rtl::OUString suStr = rtl::OUString::createFromAscii(" trim this");
+
+ sal_uInt32 nLength = suStr.getLength() * sizeof(sal_Unicode);
+ sal_Unicode *pStr = (sal_Unicode*)malloc(nLength);
+ memcpy(pStr, suStr.getStr(), nLength);
+
+ rtl_ustr_trim_WithLength( pStr, 11 );
+
+ CPPUNIT_ASSERT_MESSAGE("string should contain 'trim'", rtl::OUString(pStr).getLength() == 4);
+ free(pStr);
+ }
+
+ void trim_WithLength_004()
+ {
+ rtl::OUString suStr = rtl::OUString::createFromAscii("\r\n\t \n\r trim \n this");
+
+ sal_uInt32 nLength = suStr.getLength() * sizeof(sal_Unicode);
+ sal_Unicode *pStr = (sal_Unicode*)malloc(nLength);
+ memcpy(pStr, suStr.getStr(), nLength);
+
+ rtl_ustr_trim_WithLength( pStr, 17 );
+
+ CPPUNIT_ASSERT_MESSAGE("string should contain 'trim'", rtl::OUString(pStr).getLength() == 4);
+ free(pStr);
+ }
+
+ void trim_WithLength_005()
+ {
+ rtl::OUString suStr = rtl::OUString::createFromAscii("\r\n\t \n\r trim \t this \n\r\t\t ");
+
+ sal_uInt32 nLength = suStr.getLength() * sizeof(sal_Unicode);
+ sal_Unicode *pStr = (sal_Unicode*)malloc(nLength);
+ memcpy(pStr, suStr.getStr(), nLength);
+
+ rtl_ustr_trim_WithLength( pStr, suStr.getLength() );
+
+ CPPUNIT_ASSERT_MESSAGE("string should contain 'trim \\t this'", rtl::OUString(pStr).getLength() == 11);
+ free(pStr);
+ }
+
+ // 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(trim_WithLength);
+ CPPUNIT_TEST(trim_WithLength_000);
+ CPPUNIT_TEST(trim_WithLength_000_1);
+ CPPUNIT_TEST(trim_WithLength_001);
+ CPPUNIT_TEST(trim_WithLength_002);
+ CPPUNIT_TEST(trim_WithLength_003);
+ CPPUNIT_TEST(trim_WithLength_004);
+ CPPUNIT_TEST(trim_WithLength_005);
+ CPPUNIT_TEST_SUITE_END();
+ };
+
+ // -----------------------------------------------------------------------------
+
+ class valueOfChar : public CppUnit::TestFixture
+ {
+ public:
+ void valueOfChar_000()
+ {
+ rtl_ustr_valueOfChar(NULL, 0);
+ // should not GPF
+ }
+ void valueOfChar_001()
+ {
+ sal_Unicode *pStr = (sal_Unicode*)malloc(RTL_USTR_MAX_VALUEOFCHAR);
+ if (pStr)
+ {
+ rtl_ustr_valueOfChar(pStr, 'A');
+
+ CPPUNIT_ASSERT_MESSAGE("string should contain 'A'", pStr[0] == L'A');
+ free(pStr);
+ }
+ }
+
+ // 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(valueOfChar);
+ CPPUNIT_TEST(valueOfChar_000);
+ CPPUNIT_TEST(valueOfChar_001);
+ CPPUNIT_TEST_SUITE_END();
+ };
+
+
+
+
+ class ascii_compare_WithLength : public CppUnit::TestFixture
+ {
+ public:
+ void zero_length()
+ {
+ sal_Unicode pUnicode[] = {0xffff, 0xffff};
+ char const * pAscii = "reference";
+
+ sal_Int32 value = rtl_ustr_ascii_compare_WithLength(pUnicode, 0, pAscii);
+ CPPUNIT_ASSERT_MESSAGE("ref string is empty, compare failed, needs to be <0.", value < 0);
+ }
+
+ void equal_ascii_shorter()
+ {
+ rtl::OUString refStr(RTL_CONSTASCII_USTRINGPARAM("referenceString"));
+ char const * pAscii = "reference";
+
+ sal_Int32 value = rtl_ustr_ascii_compare_WithLength(refStr.pData->buffer, refStr.pData->length, pAscii);
+ CPPUNIT_ASSERT_MESSAGE("ref string is bigger, compare failed, needs to be >0.", value > 0);
+ }
+
+ void equal_ascii_shorter_asciiLength()
+ {
+ rtl::OUString refStr(RTL_CONSTASCII_USTRINGPARAM("referenceString"));
+ char const * pAscii = "reference";
+
+ sal_Int32 value = rtl_ustr_ascii_compare_WithLength(refStr.pData->buffer, rtl_str_getLength(pAscii), pAscii);
+ CPPUNIT_ASSERT_MESSAGE("ref string is bigger despite ascii length, compare failed, needs to be == 0.", value == 0);
+ }
+
+ void equal_ref_shorter()
+ {
+ rtl::OUString refStr(RTL_CONSTASCII_USTRINGPARAM("reference"));
+ char const * pAscii = "referenceString";
+
+ sal_Int32 value = rtl_ustr_ascii_compare_WithLength(refStr.pData->buffer, refStr.pData->length, pAscii);
+ CPPUNIT_ASSERT_MESSAGE("ascii string is bigger, but only compared to ref length, needs to be 0.", value < 0);
+ }
+
+ void equal()
+ {
+ rtl::OUString refStr(RTL_CONSTASCII_USTRINGPARAM("reference"));
+ char const * pAscii = "reference";
+
+ sal_Int32 value = rtl_ustr_ascii_compare_WithLength(refStr.pData->buffer, refStr.pData->length, pAscii);
+ CPPUNIT_ASSERT_MESSAGE("strings are equal, compare failed, needs to be 0.", value == 0);
+ }
+
+ void unequal_reference_bigger()
+ {
+ rtl::OUString refStr(RTL_CONSTASCII_USTRINGPARAM("defghi"));
+ char const * pAscii = "abc";
+
+ sal_Int32 value = rtl_ustr_ascii_compare_WithLength(refStr.pData->buffer, refStr.pData->length, pAscii);
+ CPPUNIT_ASSERT_MESSAGE("strings are unequal and ref is bigger, needs to be >0.", value > 0);
+ }
+
+ void unequal_ascii_bigger()
+ {
+ rtl::OUString refStr(RTL_CONSTASCII_USTRINGPARAM("abc"));
+ char const * pAscii = "defghi";
+
+ sal_Int32 value = rtl_ustr_ascii_compare_WithLength(refStr.pData->buffer, refStr.pData->length, pAscii);
+
+ CPPUNIT_ASSERT_MESSAGE("strings are unequal and ascii is bigger, needs to be <0.", value < 0);
+ }
+
+ CPPUNIT_TEST_SUITE(ascii_compare_WithLength);
+ CPPUNIT_TEST(zero_length);
+ CPPUNIT_TEST(equal_ascii_shorter);
+ CPPUNIT_TEST(equal_ascii_shorter_asciiLength);
+ CPPUNIT_TEST(equal_ref_shorter);
+ CPPUNIT_TEST(equal);
+ CPPUNIT_TEST(unequal_reference_bigger);
+ CPPUNIT_TEST(unequal_ascii_bigger);
+ CPPUNIT_TEST_SUITE_END();
+ };
+
+
+
+
+ class ascii_shortenedCompareIgnoreAsciiCase_WithLength : public CppUnit::TestFixture
+ {
+ public:
+
+ void ascii_shortenedCompareIgnoreAsciiCase_WithLength_000()
+ {
+ rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( NULL, 0, NULL, 0);
+ // should not GPF
+ }
+
+ void ascii_shortenedCompareIgnoreAsciiCase_WithLength_000_1()
+ {
+ rtl::OUString aStr1 = rtl::OUString::createFromAscii("Line must be equal.");
+ rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( aStr1.getStr(), aStr1.getLength(), NULL, 0);
+ // should not GPF
+ }
+ void ascii_shortenedCompareIgnoreAsciiCase_WithLength_000_2()
+ {
+ rtl::OUString aStr1 = rtl::OUString::createFromAscii("Line must be equal.");
+ rtl::OString sStr2 = "Line is shorter.";
+ rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( aStr1.getStr(), sStr2.getLength(), sStr2.getStr(), 0);
+ // should not GPF
+ }
+ void ascii_shortenedCompareIgnoreAsciiCase_WithLength_001()
+ {
+ rtl::OUString suStr1;
+ rtl::OString sStr2;
+
+ sal_Int32 nValue = rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( suStr1, 0, sStr2.getStr(), 0);
+ CPPUNIT_ASSERT_MESSAGE("compare failed, strings are equal.", nValue == 0);
+ }
+
+ void ascii_shortenedCompareIgnoreAsciiCase_WithLength_002()
+ {
+ rtl::OUString suStr1 = rtl::OUString::createFromAscii("Line must be equal.");
+ rtl::OString sStr2 = "Line must be equal.";
+
+ sal_Int32 nValue = rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( suStr1.getStr(), suStr1.getLength(), sStr2.getStr(), sStr2.getLength());
+ CPPUNIT_ASSERT_MESSAGE("compare failed, strings are equal.", nValue == 0);
+ }
+
+ void ascii_shortenedCompareIgnoreAsciiCase_WithLength_003()
+ {
+ rtl::OUString suStr1 = rtl::OUString::createFromAscii("Line must differ.");
+ rtl::OString sStr2 = "Line must be differ and longer.";
+
+ sal_Int32 nValue = rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( suStr1.getStr(), suStr1.getLength(), sStr2.getStr(), sStr2.getLength());
+ CPPUNIT_ASSERT_MESSAGE("compare failed, strings differ.", nValue != 0);
+ }
+
+ // 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(ascii_shortenedCompareIgnoreAsciiCase_WithLength);
+ CPPUNIT_TEST(ascii_shortenedCompareIgnoreAsciiCase_WithLength_000);
+ CPPUNIT_TEST(ascii_shortenedCompareIgnoreAsciiCase_WithLength_000_1);
+ CPPUNIT_TEST(ascii_shortenedCompareIgnoreAsciiCase_WithLength_000_2);
+ CPPUNIT_TEST(ascii_shortenedCompareIgnoreAsciiCase_WithLength_001);
+ CPPUNIT_TEST(ascii_shortenedCompareIgnoreAsciiCase_WithLength_002);
+ CPPUNIT_TEST(ascii_shortenedCompareIgnoreAsciiCase_WithLength_003);
+ CPPUNIT_TEST_SUITE_END();
+ }; // class ascii_shortenedCompareIgnoreAsciiCase_WithLength
+
+// -----------------------------------------------------------------------------
+
+ class ascii_compareIgnoreAsciiCase_WithLength : public CppUnit::TestFixture
+ {
+ public:
+
+ void ascii_compareIgnoreAsciiCase_WithLength_000()
+ {
+ rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( NULL, 0, NULL);
+ // should not GPF
+ }
+
+ void ascii_compareIgnoreAsciiCase_WithLength_000_1()
+ {
+ rtl::OUString aStr1 = rtl::OUString::createFromAscii("Line must be equal.");
+ rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( aStr1.getStr(), 0, NULL);
+ // should not GPF
+ }
+ void ascii_compareIgnoreAsciiCase_WithLength_000_2()
+ {
+ rtl::OUString aStr1 = rtl::OUString::createFromAscii("Line must be equal.");
+ rtl::OString sStr2 = "Line is shorter.";
+ rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( aStr1.getStr(), sStr2.getLength(), sStr2.getStr());
+ // should not GPF
+ }
+ void ascii_compareIgnoreAsciiCase_WithLength_001()
+ {
+ rtl::OUString suStr1;
+ rtl::OString sStr2;
+
+ sal_Int32 nValue = rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( suStr1, 0, sStr2.getStr());
+ CPPUNIT_ASSERT_MESSAGE("compareIgnoreAsciiCase_WithLength failed, strings are equal.", nValue == 0);
+ }
+
+ void ascii_compareIgnoreAsciiCase_WithLength_002()
+ {
+ rtl::OUString suStr1 = rtl::OUString::createFromAscii("Line must be equal.");
+ rtl::OString sStr2 = "Line must be equal.";
+
+ sal_Int32 nValue = rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( suStr1.getStr(), suStr1.getLength(), sStr2.getStr());
+ CPPUNIT_ASSERT_MESSAGE("compare failed, strings are equal.", nValue == 0);
+ }
+
+ void ascii_compareIgnoreAsciiCase_WithLength_003()
+ {
+ rtl::OUString suStr1 = rtl::OUString::createFromAscii("Line must differ.");
+ rtl::OString sStr2 = "Line must be differ and longer.";
+
+ sal_Int32 nValue = rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( suStr1.getStr(), suStr1.getLength(), sStr2.getStr());
+ CPPUNIT_ASSERT_MESSAGE("compare failed, strings differ.", nValue != 0);
+ }
+
+ // 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(ascii_compareIgnoreAsciiCase_WithLength);
+ CPPUNIT_TEST(ascii_compareIgnoreAsciiCase_WithLength_000);
+ CPPUNIT_TEST(ascii_compareIgnoreAsciiCase_WithLength_000_1);
+ CPPUNIT_TEST(ascii_compareIgnoreAsciiCase_WithLength_000_2);
+ CPPUNIT_TEST(ascii_compareIgnoreAsciiCase_WithLength_001);
+ CPPUNIT_TEST(ascii_compareIgnoreAsciiCase_WithLength_002);
+ CPPUNIT_TEST(ascii_compareIgnoreAsciiCase_WithLength_003);
+ CPPUNIT_TEST_SUITE_END();
+ }; // class ascii_compareIgnoreAsciiCase_WithLength
+
+// -----------------------------------------------------------------------------
+
+ class ascii_compare : public CppUnit::TestFixture
+ {
+ public:
+
+ void ascii_compare_000()
+ {
+ rtl_ustr_ascii_compare( NULL, NULL);
+ // should not GPF
+ }
+
+ void ascii_compare_000_1()
+ {
+ rtl::OUString aStr1 = rtl::OUString::createFromAscii("Line must be equal.");
+ rtl_ustr_ascii_compare( aStr1.getStr(), NULL);
+ // should not GPF
+ }
+ void ascii_compare_001()
+ {
+ rtl::OUString suStr1;
+ rtl::OString sStr2;
+
+ sal_Int32 nValue = rtl_ustr_ascii_compare( suStr1, sStr2.getStr());
+ CPPUNIT_ASSERT_MESSAGE("compare failed, strings are equal.", nValue == 0);
+ }
+
+ void ascii_compare_002()
+ {
+ rtl::OUString suStr1 = rtl::OUString::createFromAscii("Line must be equal.");
+ rtl::OString sStr2 = "Line must be equal.";
+
+ sal_Int32 nValue = rtl_ustr_ascii_compare( suStr1.getStr(), sStr2.getStr());
+ CPPUNIT_ASSERT_MESSAGE("compare failed, strings are equal.", nValue == 0);
+ }
+
+ void ascii_compare_003()
+ {
+ rtl::OUString suStr1 = rtl::OUString::createFromAscii("Line must differ.");
+ rtl::OString sStr2 = "Line foo bar, ok, differ.";
+
+ sal_Int32 nValue = rtl_ustr_ascii_compare( suStr1.getStr(), sStr2.getStr());
+ CPPUNIT_ASSERT_MESSAGE("compare failed, strings differ.", nValue != 0);
+ }
+
+ // 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(ascii_compare);
+ CPPUNIT_TEST(ascii_compare_000);
+ CPPUNIT_TEST(ascii_compare_000_1);
+ CPPUNIT_TEST(ascii_compare_001);
+ CPPUNIT_TEST(ascii_compare_002);
+ CPPUNIT_TEST(ascii_compare_003);
+ CPPUNIT_TEST_SUITE_END();
+ }; // class ascii_compare
+
+// -----------------------------------------------------------------------------
+
+ class ascii_compareIgnoreAsciiCase : public CppUnit::TestFixture
+ {
+ public:
+
+ void ascii_compareIgnoreAsciiCase_000()
+ {
+ rtl_ustr_ascii_compareIgnoreAsciiCase( NULL, NULL);
+ // should not GPF
+ }
+
+ void ascii_compareIgnoreAsciiCase_000_1()
+ {
+ rtl::OUString aStr1 = rtl::OUString::createFromAscii("Line must be equal.");
+ rtl_ustr_ascii_compareIgnoreAsciiCase( aStr1.getStr(), NULL);
+ // should not GPF
+ }
+ void ascii_compareIgnoreAsciiCase_001()
+ {
+ rtl::OUString suStr1;
+ rtl::OString sStr2;
+
+ sal_Int32 nValue = rtl_ustr_ascii_compareIgnoreAsciiCase( suStr1, sStr2.getStr());
+ CPPUNIT_ASSERT_MESSAGE("compare failed, strings are equal.", nValue == 0);
+ }
+
+ void ascii_compareIgnoreAsciiCase_002()
+ {
+ rtl::OUString suStr1 = rtl::OUString::createFromAscii("Line must be equal.");
+ rtl::OString sStr2 = "Line must be equal.";
+
+ sal_Int32 nValue = rtl_ustr_ascii_compareIgnoreAsciiCase( suStr1.getStr(), sStr2.getStr());
+ CPPUNIT_ASSERT_MESSAGE("compare failed, strings are equal.", nValue == 0);
+ }
+
+ void ascii_compareIgnoreAsciiCase_002_1()
+ {
+ rtl::OUString suStr1 = rtl::OUString::createFromAscii("Line must be equal, when ignore case.");
+ rtl::OString sStr2 = "LINE MUST BE EQUAL, WHEN IGNORE CASE.";
+
+ sal_Int32 nValue = rtl_ustr_ascii_compareIgnoreAsciiCase( suStr1.getStr(), sStr2.getStr());
+ CPPUNIT_ASSERT_MESSAGE("compare failed, strings are equal (if case insensitve).", nValue == 0);
+ }
+
+ void ascii_compareIgnoreAsciiCase_003()
+ {
+ rtl::OUString suStr1 = rtl::OUString::createFromAscii("Line must differ.");
+ rtl::OString sStr2 = "Line foo bar, ok, differ.";
+
+ sal_Int32 nValue = rtl_ustr_ascii_compareIgnoreAsciiCase( suStr1.getStr(), sStr2.getStr());
+ CPPUNIT_ASSERT_MESSAGE("compare failed, strings differ.", nValue != 0);
+ }
+
+ //! LLA: some more tests with some high level strings
+
+ // void ascii_compareIgnoreAsciiCase_001()
+ // {
+ // rtl::OUString suStr1 = rtl::OUString::createFromAscii("change this to ascii upper case.");
+ // rtl::OUString aShouldStr1 = rtl::OUString::createFromAscii("CHANGE THIS TO ASCII UPPER CASE.");
+ //
+ // sal_uInt32 nLength = suStr1.getLength() * sizeof(sal_Unicode);
+ // sal_Unicode* pStr = (sal_Unicode*) malloc(nLength + sizeof(sal_Unicode)); // length + null terminator
+ // CPPUNIT_ASSERT_MESSAGE("can't get memory for test", pStr != NULL);
+ // memset(pStr, 0, nLength + sizeof(sal_Unicode));
+ // memcpy(pStr, suStr1.getStr(), nLength);
+ //
+ // rtl_ustr_ascii_compareIgnoreAsciiCase( pStr );
+ // rtl::OUString suStr(pStr, suStr1.getLength());
+ //
+ // CPPUNIT_ASSERT_MESSAGE("failed", aShouldStr1.equals(suStr) == sal_True);
+ // free(pStr);
+ // }
+
+ // 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(ascii_compareIgnoreAsciiCase);
+ CPPUNIT_TEST(ascii_compareIgnoreAsciiCase_000);
+ CPPUNIT_TEST(ascii_compareIgnoreAsciiCase_000_1);
+ CPPUNIT_TEST(ascii_compareIgnoreAsciiCase_001);
+ CPPUNIT_TEST(ascii_compareIgnoreAsciiCase_002);
+ CPPUNIT_TEST(ascii_compareIgnoreAsciiCase_002_1);
+ CPPUNIT_TEST(ascii_compareIgnoreAsciiCase_003);
+ CPPUNIT_TEST_SUITE_END();
+ }; // class ascii_compareIgnoreAsciiCase
+
+
+ // sample out of inc/rtl/ustring.hxx
+ // rtl_uString * pToken = NULL;
+ // sal_Int32 nIndex = 0;
+ // do
+ // {
+ // ...
+ // nIndex = rtl_uString_getToken(&pToken, pStr, 0, ';', nIndex);
+ // ...
+ // }
+ // while (nIndex >= 0);
+
+ class getToken : public CppUnit::TestFixture
+ {
+ public:
+
+ void getToken_000()
+ {
+ rtl_ustr_ascii_compareIgnoreAsciiCase( NULL, NULL);
+ // should not GPF
+ }
+
+ void ascii_compareIgnoreAsciiCase_000_1()
+ {
+ rtl::OUString aStr1 = rtl::OUString::createFromAscii("Line must be equal.");
+ rtl_ustr_ascii_compareIgnoreAsciiCase( aStr1.getStr(), NULL);
+ // should not GPF
+ }
+ void ascii_compareIgnoreAsciiCase_001()
+ {
+ rtl::OUString suStr1;
+ rtl::OString sStr2;
+
+ sal_Int32 nValue = rtl_ustr_ascii_compareIgnoreAsciiCase( suStr1, sStr2.getStr());
+ CPPUNIT_ASSERT_MESSAGE("compare failed, strings are equal.", nValue == 0);
+ }
+
+ void ascii_compareIgnoreAsciiCase_002()
+ {
+ rtl::OUString suStr1 = rtl::OUString::createFromAscii("Line must be equal.");
+ rtl::OString sStr2 = "Line must be equal.";
+
+ sal_Int32 nValue = rtl_ustr_ascii_compareIgnoreAsciiCase( suStr1.getStr(), sStr2.getStr());
+ CPPUNIT_ASSERT_MESSAGE("compare failed, strings are equal.", nValue == 0);
+ }
+
+ void ascii_compareIgnoreAsciiCase_002_1()
+ {
+ rtl::OUString suStr1 = rtl::OUString::createFromAscii("Line must be equal, when ignore case.");
+ rtl::OString sStr2 = "LINE MUST BE EQUAL, WHEN IGNORE CASE.";
+
+ sal_Int32 nValue = rtl_ustr_ascii_compareIgnoreAsciiCase( suStr1.getStr(), sStr2.getStr());
+ CPPUNIT_ASSERT_MESSAGE("compare failed, strings are equal (if case insensitve).", nValue == 0);
+ }
+
+ void ascii_compareIgnoreAsciiCase_003()
+ {
+ rtl::OUString suStr1 = rtl::OUString::createFromAscii("Line must differ.");
+ rtl::OString sStr2 = "Line foo bar, ok, differ.";
+
+ sal_Int32 nValue = rtl_ustr_ascii_compareIgnoreAsciiCase( suStr1.getStr(), sStr2.getStr());
+ CPPUNIT_ASSERT_MESSAGE("compare failed, strings differ.", nValue != 0);
+ }
+
+ //! LLA: some more tests with some high level strings
+
+ // void ascii_compareIgnoreAsciiCase_001()
+ // {
+ // rtl::OUString suStr1 = rtl::OUString::createFromAscii("change this to ascii upper case.");
+ // rtl::OUString aShouldStr1 = rtl::OUString::createFromAscii("CHANGE THIS TO ASCII UPPER CASE.");
+ //
+ // sal_uInt32 nLength = suStr1.getLength() * sizeof(sal_Unicode);
+ // sal_Unicode* pStr = (sal_Unicode*) malloc(nLength + sizeof(sal_Unicode)); // length + null terminator
+ // CPPUNIT_ASSERT_MESSAGE("can't get memory for test", pStr != NULL);
+ // memset(pStr, 0, nLength + sizeof(sal_Unicode));
+ // memcpy(pStr, suStr1.getStr(), nLength);
+ //
+ // rtl_ustr_ascii_compareIgnoreAsciiCase( pStr );
+ // rtl::OUString suStr(pStr, suStr1.getLength());
+ //
+ // CPPUNIT_ASSERT_MESSAGE("failed", aShouldStr1.equals(suStr) == sal_True);
+ // free(pStr);
+ // }
+
+ // 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(ascii_compareIgnoreAsciiCase);
+ CPPUNIT_TEST(ascii_compareIgnoreAsciiCase_000);
+ CPPUNIT_TEST(ascii_compareIgnoreAsciiCase_000_1);
+ CPPUNIT_TEST(ascii_compareIgnoreAsciiCase_001);
+ CPPUNIT_TEST(ascii_compareIgnoreAsciiCase_002);
+ CPPUNIT_TEST(ascii_compareIgnoreAsciiCase_002_1);
+ CPPUNIT_TEST(ascii_compareIgnoreAsciiCase_003);
+ CPPUNIT_TEST_SUITE_END();
+ }; // class ascii_compareIgnoreAsciiCase
+
+// -----------------------------------------------------------------------------
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_ustr::compare, "rtl_ustr");
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_ustr::compareIgnoreAsciiCase, "rtl_ustr");
+
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_ustr::ascii_compare_WithLength, "rtl_ustr");
+
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_ustr::shortenedCompareIgnoreAsciiCase_WithLength, "rtl_ustr");
+// CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_ustr::hashCode, "rtl_ustr");
+
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_ustr::indexOfChar, "rtl_ustr");
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_ustr::lastIndexOfChar, "rtl_ustr");
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_ustr::indexOfStr, "rtl_ustr");
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_ustr::lastIndexOfStr, "rtl_ustr");
+
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_ustr::replaceChar, "rtl_ustr");
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_ustr::replaceChar_WithLength, "rtl_ustr");
+
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_ustr::toAsciiLowerCase, "rtl_ustr");
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_ustr::toAsciiLowerCase_WithLength, "rtl_ustr");
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_ustr::toAsciiUpperCase, "rtl_ustr");
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_ustr::toAsciiUpperCase_WithLength, "rtl_ustr");
+
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_ustr::trim_WithLength, "rtl_ustr");
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_ustr::valueOfChar, "rtl_ustr");
+
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_ustr::ascii_compare, "rtl_ustr");
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_ustr::ascii_compareIgnoreAsciiCase, "rtl_ustr");
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_ustr::ascii_compareIgnoreAsciiCase_WithLength, "rtl_ustr");
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_ustr::ascii_shortenedCompareIgnoreAsciiCase_WithLength, "rtl_ustr");
+
+} // namespace rtl_ustr
+
+// -----------------------------------------------------------------------------
+
+// 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/oustring/rtl_ustr.xsce b/sal/qa/rtl/oustring/rtl_ustr.xsce
new file mode 100644
index 000000000000..0c098eb83571
--- /dev/null
+++ b/sal/qa/rtl/oustring/rtl_ustr.xsce
@@ -0,0 +1,33 @@
+# functions which are gpf
+
+rtl_ustr.compare.compare_000
+rtl_ustr.compare.compare_000_1
+
+rtl_ustr.compareIgnoreAsciiCase.compare_000
+rtl_ustr.compareIgnoreAsciiCase.compare_000_1
+
+rtl_ustr.indexOfChar.indexOfChar_000
+
+rtl_ustr.lastIndexOfChar.lastIndexOfChar_000
+
+rtl_ustr.indexOfStr.indexOfStr_000
+
+rtl_ustr.lastIndexOfStr.lastIndexOfStr_000
+
+rtl_ustr.replaceChar.replaceChar_000
+
+rtl_ustr.replaceChar_WithLength.replaceChar_WithLength_000_1
+
+rtl_ustr.toAsciiLowerCase.toAsciiLowerCase_000
+
+rtl_ustr.toAsciiUpperCase.toAsciiUpperCase_000
+
+rtl_ustr.valueOfChar.valueOfChar_000
+
+rtl_ustr.ascii_compare.ascii_compare_000
+rtl_ustr.ascii_compare.ascii_compare_000_1
+rtl_ustr.ascii_compareIgnoreAsciiCase.ascii_compareIgnoreAsciiCase_000
+rtl_ustr.ascii_compareIgnoreAsciiCase.ascii_compareIgnoreAsciiCase_000_1
+rtl_ustr.ascii_compareIgnoreAsciiCase_WithLength.ascii_compareIgnoreAsciiCase_WithLength_000
+rtl_ustr.ascii_compareIgnoreAsciiCase_WithLength.ascii_compareIgnoreAsciiCase_WithLength_000_1
+