1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_sal.hxx" 26 27 // LLA: 28 // this file is converted to use with testshl2 29 // original was placed in sal/test/textenc.cxx 30 31 32 // ----------------------------------------------------------------------------- 33 #include <string.h> 34 #include <stdio.h> 35 36 #ifdef UNX 37 #include <wchar.h> 38 #endif 39 #ifdef OS2__00 40 #include <wcstr.h> 41 #endif 42 43 // #ifndef _OSL_DIAGNOSE_H_ 44 // #include <osl/diagnose.h> 45 // #endif 46 47 #ifndef _RTL_USTRING_HXX 48 #include <rtl/ustring.hxx> 49 #endif 50 51 #ifndef _RTL_STRING_HXX 52 #include <rtl/string.hxx> 53 #endif 54 55 #include <rtl/locale.hxx> 56 57 #include <testshl/simpleheader.hxx> 58 59 #define TEST_ENSURE(c, m) CPPUNIT_ASSERT_MESSAGE((m), (c)) 60 // #if OSL_DEBUG_LEVEL > 0 61 // #define TEST_ENSHURE(c, m) OSL_ENSURE(c, m) 62 // #else 63 // #define TEST_ENSHURE(c, m) OSL_VERIFY(c) 64 // #endif 65 66 using namespace rtl; 67 68 // ----------------------------------------------------------------------------- 69 namespace rtl_OUString 70 { 71 class oldtests : public CppUnit::TestFixture 72 { 73 public: 74 void test_OUString(); 75 void test_OString2OUStringAndViceVersa(); 76 77 CPPUNIT_TEST_SUITE( oldtests ); 78 CPPUNIT_TEST( test_OUString ); 79 CPPUNIT_TEST( test_OString2OUStringAndViceVersa ); 80 CPPUNIT_TEST_SUITE_END( ); 81 }; 82 83 84 void oldtests::test_OUString() 85 { 86 // "Mein erster RTL OUString\n" 87 // | | | | | 88 // Index 0 5 10 15 20 89 OUString s1(OUString::createFromAscii("Mein erster RTL OUString\n")); 90 TEST_ENSURE( s1 == OUString::createFromAscii("Mein erster RTL OUString\n"), "test_OWString error 1"); 91 TEST_ENSURE( s1.getLength() == 25, "test_OWString error 2"); 92 93 OUString s2 = s1; 94 TEST_ENSURE( s2[16] == (sal_Unicode)'O', "test_OWString error 3"); 95 TEST_ENSURE( s2.equals(s1), "test_OWString error 4"); 96 TEST_ENSURE( OUString( OUString::createFromAscii("hallo")) == OUString::createFromAscii( "hallo"), "test_OWString error 4"); 97 TEST_ENSURE( s2.indexOf((sal_Unicode)'O') == 16, "test_OWString error 5"); 98 TEST_ENSURE( s2.indexOf((sal_Unicode)'O', 5) == 16, "test_OWString error 5a"); 99 TEST_ENSURE( s2.lastIndexOf((sal_Unicode)'r') == 20, "test_OWString error 6"); 100 TEST_ENSURE( s2[20] == (sal_Unicode)'r', "test_OWString error 7"); 101 TEST_ENSURE( s2[24] == (sal_Unicode)'\n', "test_OWString error 8"); 102 TEST_ENSURE( s2.lastIndexOf((sal_Unicode)'\n') == 24, "test_OWString error 9"); 103 TEST_ENSURE( s2.lastIndexOf((sal_Unicode)'M') == 0, "test_OWString error 10"); 104 TEST_ENSURE( s2.lastIndexOf((sal_Unicode)'t', s2.getLength() - 8) == 8, "test_OWString error 9"); 105 106 107 // "Mein erster RTL OUString ist ein String aus der RTL Library\n" 108 // | | | | | | | | | | | | 109 // Index 0 5 10 15 20 25 30 35 40 45 50 55 110 OUString s3 = s2.copy(0, s2.getLength() - 1); 111 OUString s4 = s3.concat( OUString::createFromAscii(" ist ein String aus der RTL Library\n") ); 112 TEST_ENSURE( s4.getLength() == 60, "test_OWString error 11"); 113 114 s1 = s4.copy(0, 39); 115 OUString s5; 116 s5 = s1 + OUString::createFromAscii( " aus der RTL Library\n" ); 117 TEST_ENSURE( s5.compareTo(s4) == 0 , "test_OWString error 12"); 118 TEST_ENSURE( s5.indexOf(OUString::createFromAscii("RTL")) == 12, "test_OWString error 13"); 119 TEST_ENSURE( s5.lastIndexOf(OUString::createFromAscii("RTL")) == 48, "test_OWString error 13"); 120 121 sal_Bool b = sal_False; 122 OUString s6 = s5.valueOf(b); 123 // TEST_ENSURE( s6.compareTo(OUString::createFromAscii("False")) == 0, "test_OWString error 14"); 124 s6 = s5.valueOf((sal_Unicode)'H'); 125 TEST_ENSURE( s6.compareTo(OUString::createFromAscii("H")) == 0, "test_OWString error 15"); 126 sal_Int32 n = 123456789L; 127 s6 = s5.valueOf(n); 128 TEST_ENSURE( s6.compareTo(OUString::createFromAscii("123456789")) == 0, "test_OWString error 16"); 129 130 #ifndef SAL_OS2 131 #ifdef SAL_UNX 132 sal_Int64 m = -3223372036854775807LL; 133 #elif defined(SAL_OS2) 134 sal_Int64 m; 135 sal_setInt64(&m, 3965190145L, -750499787L); 136 #else 137 sal_Int64 m = -3223372036854775807; 138 #endif 139 s6 = s5.valueOf(m); 140 TEST_ENSURE( s6.compareTo( OUString::createFromAscii( "-3223372036854775807" ) ) == 0, "test_OWString error 17"); 141 #endif 142 143 // LLA: locale tests removed ::rtl::OLocale locale = ::rtl::OLocale::getDefault(); 144 // LLA: locale tests removed 145 // LLA: locale tests removed OUString s61(OUString::createFromAscii("HaLLo")); 146 // LLA: locale tests removed s61 = s61.toLowerCase(locale); 147 // LLA: locale tests removed TEST_ENSURE( s61 == OUString::createFromAscii("hallo"), "test_OWString error 17a"); 148 // LLA: locale tests removed s61 = s61.toUpperCase(); 149 // LLA: locale tests removed TEST_ENSURE( s61 == OUString::createFromAscii("HALLO"), "test_OWString error 17b"); 150 // LLA: locale tests removed s61 = s61.toLowerCase(); 151 // LLA: locale tests removed TEST_ENSURE( s61 == OUString::createFromAscii("hallo"), "test_OWString error 17c"); 152 // LLA: locale tests removed 153 // LLA: locale tests removed ::rtl::OLocale::setDefault( OUString::createFromAscii( "de" ), OUString::createFromAscii( "DE" ), OUString() ); 154 // LLA: locale tests removed locale = OLocale::getDefault(); 155 // LLA: locale tests removed 156 // LLA: locale tests removed // AB, 24.3.2000, removed NAMESPACE_RTL(OLocale)::getENGLISH() and error 18 157 // LLA: locale tests removed 158 // LLA: locale tests removed OUString s7(OUString::createFromAscii("HaLLo")); 159 // LLA: locale tests removed s7 = s7.toLowerCase(locale); 160 // LLA: locale tests removed TEST_ENSURE( s7 == OUString::createFromAscii("hallo"), "test_OWString error 19"); 161 // LLA: locale tests removed s7 = s7.toUpperCase(locale); 162 // LLA: locale tests removed TEST_ENSURE( s7 == OUString::createFromAscii("HALLO"), "test_OWString error 20"); 163 // LLA: locale tests removed 164 // LLA: locale tests removed OUString s8(OUString::createFromAscii("HaLLo ICH BIn eIn ")); 165 // LLA: locale tests removed s8 += OUString::valueOf( (sal_Unicode)0xDF ); 166 // LLA: locale tests removed locale = OLocale::registerLocale( OUString::createFromAscii("tr"), OUString::createFromAscii("TR"), OUString()); 167 // LLA: locale tests removed s8 = s8.toLowerCase(locale); 168 // LLA: locale tests removed s8 = s8.toUpperCase(locale); 169 // LLA: locale tests removed TEST_ENSURE( s8 == OUString::createFromAscii("HALLO ICH BIN EIN SS"), "test_OWString error 21"); 170 // LLA: locale tests removed 171 // LLA: locale tests removed s7 = OUString::createFromAscii("Hallo ich bIn ein I"); 172 // LLA: locale tests removed s7 = s8.toUpperCase(locale); 173 // LLA: locale tests removed TEST_ENSURE( s7 != OUString::createFromAscii("HALLO ICH BIN EIN I"), "test_OWString error 21.b"); 174 175 OUString s7; 176 OUString s8(OUString::createFromAscii("HALLO ICH BIN EIN SS")); 177 s7 = OUString::createFromAscii(" "); 178 s8 = s7 + s8 + OUString::createFromAscii(" " ); 179 TEST_ENSURE( s8 == OUString::createFromAscii(" HALLO ICH BIN EIN SS "), 180 "test_OWString error 22"); 181 182 s7 = s8.trim(); 183 TEST_ENSURE( s7 == OUString::createFromAscii("HALLO ICH BIN EIN SS"), "test_OWString error 23"); 184 // TEST_ENSURE( wcscmp(s7.getStr(), L"HALLO ICH BIN EIN SS") == 0, "test_OWString error 24"); 185 186 s7 = OUString::createFromAscii("Hallo"); 187 s8 = OUString::createFromAscii("aber Hallo"); 188 189 TEST_ENSURE( s7 < s8, "test_OWString error 25"); 190 TEST_ENSURE( s8 > s7, "test_OWString error 26"); 191 TEST_ENSURE( s7 != s8, "test_OWString error 27"); 192 TEST_ENSURE( s7 != OUString::createFromAscii("blabla"), "test_OWString error 28"); 193 TEST_ENSURE( OUString::createFromAscii("blabla") != s7, "test_OWString error 29"); 194 195 s8 = OUString::createFromAscii("Hallo"); 196 TEST_ENSURE( s7 <= s8, "test_OWString error 30"); 197 TEST_ENSURE( s7 >= s8, "test_OwString error 31"); 198 199 s8 = s8.replace((sal_Unicode)'l', (sal_Unicode)'r'); 200 TEST_ENSURE( s8 == OUString::createFromAscii("Harro"), "test_OWString error 32"); 201 // LLA: len() unknown TEST_ENSURE( s8.len() == 5, "test_OWString error 33"); 202 203 // "Ich bin ein String mit einem A und C und vielen m, m, m, m" 204 // | | | | | | | | | | | | 205 //index 0 5 10 15 20 25 30 35 40 45 50 55 206 s8 = OUString::createFromAscii("Ich bin ein String mit einem A und C und vielen m, m, m, m"); 207 // LLA: no matching TEST_ENSURE( s8.search((sal_Unicode)'I') == 0, "test_OWString error 34"); 208 // LLA: no matching TEST_ENSURE( s8.search((sal_Unicode)'A') == 29, "test_OWString error 35"); 209 // LLA: no matching s7 = OUString::createFromAscii("A und C"); 210 // LLA: no matching TEST_ENSURE( s8.search(s7) == 29, "test_OWString error 36"); 211 // LLA: no matching TEST_ENSURE( s8.search(OUString::createFromAscii("mit einem A")) == 19, "test_OWString error 37"); 212 // LLA: no matching 213 // LLA: no matching s8 = OUString::createFromAscii("||token1|token2|token3||token4|token5||" ); 214 // LLA: no matching TEST_ENSURE( s8.getTokenCount('|') == 10, "test_OWString error 38a"); 215 // LLA: no matching TEST_ENSURE( s8.getToken(10,'|') == OUString(), "test_OWString error 39a"); 216 // LLA: no matching 217 // LLA: no matching s8 = OUString::createFromAscii("token1"); 218 // LLA: no matching TEST_ENSURE( s8.getTokenCount('|') == 1, "test_OWString error 38b"); 219 // LLA: no matching TEST_ENSURE( s8.getToken(0,'|') == OUString::createFromAscii("token1"), "test_OWString error 39b"); 220 // LLA: no matching TEST_ENSURE( s8.getToken(-1,'|') == OUString(), "test_OWString error 39c"); 221 // LLA: no matching TEST_ENSURE( s8.getToken(1,'|') == OUString(), "test_OWString error 39d"); 222 // LLA: no matching 223 // LLA: no matching s8 = OUString::createFromAscii("|hallo1|hallo2|hallo3|hallo4|hallo5|hallo6|hallo7|hallo8|"); 224 // LLA: no matching TEST_ENSURE( s8.getTokenCount((sal_Unicode)'|') == 10, "test_OWString error 38"); 225 // LLA: no matching TEST_ENSURE( s8.getToken(3, (sal_Unicode)'|') == OUString::createFromAscii("hallo3"), "test_OWString error 39"); 226 227 // LLA: removed due to the fact, this is not a clean test! 228 229 // LLA: s7 = OUString(); 230 // LLA: s7 += s8; 231 // LLA: TEST_ENSURE( s7 == s8, "test_OWString error 40"); 232 // LLA: 233 // LLA: s7 = s8.replaceAt(8, 6, OUString::createFromAscii("mmmmmmmmmm")); 234 // LLA: TEST_ENSURE( s7.getLength() == 61, "test_OWString error 41"); 235 // LLA: 236 // LLA: s8 = s7.replaceAt(8, 11, OUString()); 237 // LLA: TEST_ENSURE( s8.getLength() == 50, "test_OWString error 42"); 238 // LLA: 239 // LLA: s7 = s8.replaceAt(8, 0, OUString::createFromAscii("hallo2|")); 240 // LLA: TEST_ENSURE( s7.getLength() == 57, "test_OWString error 43"); 241 // LLA: 242 // LLA: sal_Int32 pos = 0; 243 // LLA: while ((pos = s7.indexOf(OUString::createFromAscii("|"))) >= 0) 244 // LLA: { 245 // LLA: s8 = s7.replaceAt(pos, 1, OUString::createFromAscii("**")); 246 // LLA: s7 = s8; 247 // LLA: } 248 // LLA: TEST_ENSURE( s7.getLength() == 66, "test_OWString error 44"); 249 250 TEST_ENSURE( OUString::createFromAscii("aaa" ).compareTo( OUString::createFromAscii("bbb" ) ) < 0, "test_OWString error 46" ); 251 TEST_ENSURE( OUString::createFromAscii("aaa" ).compareTo( OUString::createFromAscii("aaa" ) ) == 0, "test_OWString error 46" ); 252 TEST_ENSURE( OUString::createFromAscii("bbb" ).compareTo( OUString::createFromAscii("aaa" ) ) > 0, "test_OWString error 47" ); 253 TEST_ENSURE( OUString::createFromAscii("aaaa" ).compareTo( OUString::createFromAscii("bbb" ) ) < 0, "test_OWString error 48" ); 254 TEST_ENSURE( OUString::createFromAscii("aaa" ).compareTo( OUString::createFromAscii("bbbb" ) ) < 0, "test_OWString error 49" ); 255 TEST_ENSURE( OUString::createFromAscii("aaa" ).compareTo( OUString::createFromAscii("aaaa" ) ) < 0, "test_OWString error 50" ); 256 TEST_ENSURE( OUString::createFromAscii("aaaa" ).compareTo( OUString::createFromAscii("aaa" ) ) > 0, "test_OWString error 51" ); 257 TEST_ENSURE( OUString::createFromAscii("bbbb" ).compareTo( OUString::createFromAscii("bbb" ) ) > 0, "test_OWString error 52" ); 258 TEST_ENSURE( OUString::createFromAscii("bbb" ) == OUString::createFromAscii("bbb" ), "test_OWString error 53" ); 259 TEST_ENSURE( OUString::createFromAscii("bbb" ) == OUString::createFromAscii("bbb" ), "test_OWString error 54" ); 260 261 { 262 OUString uStr = OUString::createFromAscii( "Hallo" ); 263 TEST_ENSURE( uStr.compareTo( OUString::createFromAscii("Hallo"), 5 ) == 0, "test_OWString error 54.2.1" ); 264 TEST_ENSURE( uStr.compareTo( OUString::createFromAscii("Halloa"), 6 ) < 0 , "test_OWString error 54.2.2" ); 265 TEST_ENSURE( uStr.compareTo( OUString::createFromAscii("1Hallo"), 6 ) > 0, "test_OWString error 54.2.3" ); 266 TEST_ENSURE( uStr.compareTo( OUString::createFromAscii("Aallo"), 5 ) > 0, "test_OWString error 54.2.4" ); 267 TEST_ENSURE( uStr.compareTo( OUString::createFromAscii("Halla"), 5 ) > 0, "test_OWString error 54.2.5" ); 268 TEST_ENSURE( uStr.compareTo( OUString::createFromAscii("Mallo"), 5 ) < 0, "test_OWString error 54.2.6" ); 269 TEST_ENSURE( uStr.compareTo( OUString::createFromAscii("Hallp"), 5 ) < 0, "test_OWString error 54.2.7" ); 270 } 271 272 #if OSL_DEBUG_LEVEL == 0 273 //YD will fail copy assert on indexes, because ':' returns -1 274 s7 = OUString::createFromAscii("Hallo jetzt komm ich"); 275 s8 = s7.copy(0, s7.indexOf((sal_Unicode)':')); 276 TEST_ENSURE( s8.getLength() == 0, "test_OWString error 55"); 277 TEST_ENSURE( s8.compareTo(OUString()) == 0, "test_OWString error 56"); 278 #endif 279 280 // ASCII-Schnittstellen, AB 15.10.1999 281 282 // "Ich bin ein reiner ASCII-String mit ein paar Zahlen 0123456789 und Zeichen" 283 // | | | | | | | | | | | | | | | 284 //index 0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 285 // 286 // "Ich bin ein weiterer ASCII-String" 287 // | | | | | | | 288 //index 0 5 10 15 20 25 30 289 sal_Char ascii_str1[] = "Ich bin ein reiner ASCII-String mit ein paar Zahlen 0123456789 und Zeichen"; 290 sal_Char ascii_str2[] = "Ich bin ein weiterer ASCII-String"; 291 OUString OWAsciiStr1 = OUString::createFromAscii( ascii_str1 ); 292 sal_Int32 nLen1 = OWAsciiStr1.getLength(); 293 TEST_ENSURE( nLen1 == 74, "test_OWString error 57" ); 294 OUString OWAsciiStr2 = OUString::createFromAscii( ascii_str2 ); 295 sal_Int32 nLen2 = OWAsciiStr2.getLength(); 296 TEST_ENSURE( nLen2 == 33, "test_OWString error 58" ); 297 298 sal_Int32 nCompareResult11 = OWAsciiStr1.compareToAscii( ascii_str1 ); 299 TEST_ENSURE( nCompareResult11 == 0, "test_OWString error 59" ); 300 sal_Int32 nCompareResult12 = OWAsciiStr1.compareToAscii( ascii_str2 ); 301 TEST_ENSURE( nCompareResult12 < 0, "test_OWString error 60" ); 302 303 sal_Int32 nCompareResult21 = OWAsciiStr2.compareToAscii( ascii_str1 ); 304 TEST_ENSURE( nCompareResult21 > 0, "test_OWString error 61" ); 305 sal_Int32 nCompareResult22 = OWAsciiStr2.compareToAscii( ascii_str2 ); 306 TEST_ENSURE( nCompareResult22 == 0, "test_OWString error 62" ); 307 308 sal_Int32 nCompareResult12_Len12 = OWAsciiStr1.compareToAscii( ascii_str2, 12 ); 309 TEST_ENSURE( nCompareResult12_Len12 == 0, "test_OWString error 63" ); 310 sal_Int32 nCompareResult12_Len13 = OWAsciiStr1.compareToAscii( ascii_str2, 13 ); 311 TEST_ENSURE( nCompareResult12_Len13 < 0, "test_OWString error 64" ); 312 313 sal_Int32 nCompareResult21_Len12 = OWAsciiStr2.compareToAscii( ascii_str1, 12 ); 314 TEST_ENSURE( nCompareResult21_Len12 == 0, "test_OWString error 65" ); 315 sal_Int32 nCompareResult21_Len13 = OWAsciiStr2.compareToAscii( ascii_str1, 13 ); 316 TEST_ENSURE( nCompareResult21_Len13 > 0, "test_OWString error 66" ); 317 318 { 319 OUString uStr = OUString::createFromAscii( "Hallo" ); 320 TEST_ENSURE( uStr.equalsAsciiL( "Hallo", 5 ), "test_OWString error 66.1.1" ); 321 TEST_ENSURE( !uStr.equalsAsciiL( "Hallo1", 6 ), "test_OWString error 66.1.2" ); 322 TEST_ENSURE( !uStr.equalsAsciiL( "1Hallo", 6 ), "test_OWString error 66.1.3" ); 323 TEST_ENSURE( !uStr.equalsAsciiL( "aallo", 5 ), "test_OWString error 66.1.2" ); 324 TEST_ENSURE( !uStr.equalsAsciiL( "Halla", 5 ), "test_OWString error 66.1.3" ); 325 326 TEST_ENSURE( uStr.reverseCompareToAsciiL( "Hallo", 5 ) == 0, "test_OWString error 66.2.1" ); 327 TEST_ENSURE( uStr.reverseCompareToAsciiL( "Halloa", 6 ) > 0 , "test_OWString error 66.2.2" ); 328 TEST_ENSURE( uStr.reverseCompareToAsciiL( "1Hallo", 6 ) < 0, "test_OWString error 66.2.3" ); 329 TEST_ENSURE( uStr.reverseCompareToAsciiL( "Aallo", 5 ) > 0, "test_OWString error 66.2.4" ); 330 TEST_ENSURE( uStr.reverseCompareToAsciiL( "Halla", 5 ) > 0, "test_OWString error 66.2.5" ); 331 TEST_ENSURE( uStr.reverseCompareToAsciiL( "Mallo", 5 ) < 0, "test_OWString error 66.2.6" ); 332 TEST_ENSURE( uStr.reverseCompareToAsciiL( "Hallp", 5 ) < 0, "test_OWString error 66.2.7" ); 333 } 334 335 // toInt64 336 OUString s9( OUString::createFromAscii(" -3223372036854775807") ); 337 sal_Int64 ln1 = s9.toInt64(); 338 #if (defined UNX) || (defined OS2) 339 TEST_ENSURE( ln1 == -3223372036854775807LL, "test_OWString error 67" ); 340 #else 341 TEST_ENSURE( ln1 == -3223372036854775807, "test_OWString error 67" ); 342 #endif 343 OUString s10( OUString::createFromAscii("13243A65f1H45") ); 344 sal_Int64 ln2 = s10.toInt64(); 345 TEST_ENSURE( ln2 == 13243, "test_OWString error 68" ); 346 347 sal_Int64 ln3 = s10.toInt64( 16 ); 348 #if (defined UNX) || (defined OS2) 349 TEST_ENSURE( ln3 == 0x13243A65F1LL, "test_OWString error 69" ); 350 #else 351 TEST_ENSURE( ln3 == 0x13243A65F1, "test_OWString error 69" ); 352 #endif 353 // Exotic base 354 OUString s11( OUString::createFromAscii("H4A") ); 355 sal_Int64 ln4 = s11.toInt64( 23 ); 356 TEST_ENSURE( ln4 == 23*23*17 + 4 * 23 + 10, "test_OWString error 70" ); 357 358 // toInt32 359 OUString s12( OUString::createFromAscii(" -220368507") ); 360 sal_Int32 n1 = s12.toInt32(); 361 TEST_ENSURE( n1 == -220368507, "test_OWString error 71" ); 362 363 OUString s13( OUString::createFromAscii("4423A61H45") ); 364 sal_Int64 n2 = s13.toInt32(); 365 TEST_ENSURE( n2 == 4423, "test_OWString error 72" ); 366 367 sal_Int64 n3 = s13.toInt64( 16 ); 368 TEST_ENSURE( n3 == 0x4423A61, "test_OWString error 73" ); 369 370 // LLA: Value tests fails most the time, this is not a good test 371 // LLA: double d = 1.23456781; 372 // LLA: OUString sDouble = OUString::valueOf( d ); 373 // LLA: char str[] = "1.2345678099999999"; 374 // LLA: sal_Int32 nLength = sDouble.getLength(); 375 // LLA: TEST_ENSURE( nLength == strlen( str ), "test_OWString error 74" ); 376 // LLA: sal_Int32 nCompare = sDouble.compareToAscii( str ); 377 // LLA: TEST_ENSURE( nCompare == 0, "test_OWString error 75" ); 378 379 printf("test_OWString OK !!!\n"); 380 return; 381 } 382 383 // ----------------------------------------------------------------------------- 384 385 void oldtests::test_OString2OUStringAndViceVersa() 386 { 387 OString s1("Hallo jetzt komm ich"); 388 OUString u1 = OStringToOUString(s1, RTL_TEXTENCODING_MS_1252); 389 TEST_ENSURE( u1.equals(OUString::createFromAscii("Hallo jetzt komm ich")), "test_OString2OWStringAndViceVersa error 1" ); 390 u1 = OStringToOUString(s1, RTL_TEXTENCODING_IBM_850); 391 TEST_ENSURE( u1.equals(OUString::createFromAscii("Hallo jetzt komm ich")), "test_OString2OWStringAndViceVersa error 2" ); 392 u1 = OStringToOUString(s1, RTL_TEXTENCODING_ISO_8859_15); 393 TEST_ENSURE( u1.equals(OUString::createFromAscii("Hallo jetzt komm ich")), "test_OString2OWStringAndViceVersa error 3" ); 394 u1 = OStringToOUString(s1, RTL_TEXTENCODING_ASCII_US); 395 TEST_ENSURE( u1.equals(OUString::createFromAscii("Hallo jetzt komm ich")), "test_OString2OWStringAndViceVersa error 4" ); 396 397 OString s2 = OUStringToOString(u1, RTL_TEXTENCODING_MS_1252); 398 TEST_ENSURE( s2.equals("Hallo jetzt komm ich"), "test_OString2OWStringAndViceVersa error 5" ); 399 s2 = OUStringToOString(u1, RTL_TEXTENCODING_IBM_850); 400 TEST_ENSURE( s2.equals("Hallo jetzt komm ich"), "test_OString2OWStringAndViceVersa error 6" ); 401 s2 = OUStringToOString(u1, RTL_TEXTENCODING_ISO_8859_15); 402 TEST_ENSURE( s2.equals("Hallo jetzt komm ich"), "test_OString2OWStringAndViceVersa error 7" ); 403 s2 = OUStringToOString(u1, RTL_TEXTENCODING_ASCII_US); 404 TEST_ENSURE( s2.equals("Hallo jetzt komm ich"), "test_OString2OWStringAndViceVersa error 8" ); 405 406 printf("test_OString2OWStringAndViceVersa OK !!!\n"); 407 } 408 409 } // namespace rtl_OUString 410 411 // ----------------------------------------------------------------------------- 412 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( rtl_OUString::oldtests, "rtl_OUString" ); 413 414 // ----------------------------------------------------------------------------- 415 NOADDITIONAL; 416 417 418