1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 29 // MARKER(update_precomp.py): autogen include statement, do not remove 30 #include "precompiled_sal.hxx" 31 #include <testshl/simpleheader.hxx> 32 #include "stringhelper.hxx" 33 #include <rtl/ustrbuf.hxx> 34 #include <rtl/uri.hxx> 35 36 namespace rtl_OUStringBuffer 37 { 38 39 40 class insertUtf32 : public CppUnit::TestFixture 41 { 42 public: 43 // initialise your test code values here. 44 void setUp() 45 { 46 } 47 48 void tearDown() 49 { 50 } 51 52 void insertUtf32_001() 53 { 54 ::rtl::OUStringBuffer aUStrBuf(4); 55 aUStrBuf.insertUtf32(0,0x10ffff); 56 57 rtl::OUString suStr = aUStrBuf.makeStringAndClear(); 58 rtl::OUString suStr2 = rtl::Uri::encode(suStr, rtl_UriCharClassUnoParamValue, rtl_UriEncodeKeepEscapes, RTL_TEXTENCODING_UTF8); 59 60 rtl::OString sStr; 61 sStr <<= suStr2; 62 t_print("%s\n", sStr.getStr()); 63 64 CPPUNIT_ASSERT_MESSAGE("Strings must be '%F4%8F%BF%BF'", sStr.equals(rtl::OString("%F4%8F%BF%BF")) == sal_True); 65 } 66 67 void insertUtf32_002() 68 { 69 ::rtl::OUStringBuffer aUStrBuf(4); 70 aUStrBuf.insertUtf32(0,0x41); 71 aUStrBuf.insertUtf32(1,0x42); 72 aUStrBuf.insertUtf32(2,0x43); 73 74 rtl::OUString suStr = aUStrBuf.makeStringAndClear(); 75 rtl::OUString suStr2 = rtl::Uri::encode(suStr, rtl_UriCharClassUnoParamValue, rtl_UriEncodeKeepEscapes, RTL_TEXTENCODING_UTF8); 76 77 rtl::OString sStr; 78 sStr <<= suStr2; 79 t_print("%s\n", sStr.getStr()); 80 81 CPPUNIT_ASSERT_MESSAGE("Strings must be 'ABC'", sStr.equals(rtl::OString("ABC")) == sal_True); 82 } 83 84 CPPUNIT_TEST_SUITE(insertUtf32); 85 CPPUNIT_TEST(insertUtf32_001); 86 CPPUNIT_TEST(insertUtf32_002); 87 CPPUNIT_TEST_SUITE_END(); 88 }; // class getToken 89 90 // ----------------------------------------------------------------------------- 91 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_OUStringBuffer::insertUtf32, "rtl_OUStringBuffer"); 92 93 } // namespace rtl_OUStringBuffer 94 95 96 // ----------------------------------------------------------------------------- 97 98 // this macro creates an empty function, which will called by the RegisterAllFunctions() 99 // to let the user the possibility to also register some functions by hand. 100 NOADDITIONAL; 101 102