1*87d2adbcSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*87d2adbcSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*87d2adbcSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*87d2adbcSAndrew Rist  * distributed with this work for additional information
6*87d2adbcSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*87d2adbcSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*87d2adbcSAndrew Rist  * "License"); you may not use this file except in compliance
9*87d2adbcSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*87d2adbcSAndrew Rist  *
11*87d2adbcSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*87d2adbcSAndrew Rist  *
13*87d2adbcSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*87d2adbcSAndrew Rist  * software distributed under the License is distributed on an
15*87d2adbcSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*87d2adbcSAndrew Rist  * KIND, either express or implied.  See the License for the
17*87d2adbcSAndrew Rist  * specific language governing permissions and limitations
18*87d2adbcSAndrew Rist  * under the License.
19*87d2adbcSAndrew Rist  *
20*87d2adbcSAndrew Rist  *************************************************************/
21*87d2adbcSAndrew Rist 
22*87d2adbcSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir 
25cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
26cdf0e10cSrcweir #include "precompiled_sal.hxx"
27cdf0e10cSrcweir #include <testshl/simpleheader.hxx>
28cdf0e10cSrcweir #include "stringhelper.hxx"
29cdf0e10cSrcweir #include <rtl/ustrbuf.hxx>
30cdf0e10cSrcweir #include <rtl/uri.hxx>
31cdf0e10cSrcweir 
32cdf0e10cSrcweir namespace rtl_OUStringBuffer
33cdf0e10cSrcweir {
34cdf0e10cSrcweir 
35cdf0e10cSrcweir 
36cdf0e10cSrcweir class insertUtf32 : public CppUnit::TestFixture
37cdf0e10cSrcweir {
38cdf0e10cSrcweir public:
39cdf0e10cSrcweir     // initialise your test code values here.
setUp()40cdf0e10cSrcweir     void setUp()
41cdf0e10cSrcweir     {
42cdf0e10cSrcweir     }
43cdf0e10cSrcweir 
tearDown()44cdf0e10cSrcweir     void tearDown()
45cdf0e10cSrcweir     {
46cdf0e10cSrcweir     }
47cdf0e10cSrcweir 
insertUtf32_001()48cdf0e10cSrcweir     void insertUtf32_001()
49cdf0e10cSrcweir         {
50cdf0e10cSrcweir             ::rtl::OUStringBuffer aUStrBuf(4);
51cdf0e10cSrcweir             aUStrBuf.insertUtf32(0,0x10ffff);
52cdf0e10cSrcweir 
53cdf0e10cSrcweir             rtl::OUString suStr = aUStrBuf.makeStringAndClear();
54cdf0e10cSrcweir             rtl::OUString suStr2 = rtl::Uri::encode(suStr, rtl_UriCharClassUnoParamValue, rtl_UriEncodeKeepEscapes, RTL_TEXTENCODING_UTF8);
55cdf0e10cSrcweir 
56cdf0e10cSrcweir             rtl::OString sStr;
57cdf0e10cSrcweir             sStr <<= suStr2;
58cdf0e10cSrcweir             t_print("%s\n", sStr.getStr());
59cdf0e10cSrcweir 
60cdf0e10cSrcweir             CPPUNIT_ASSERT_MESSAGE("Strings must be '%F4%8F%BF%BF'", sStr.equals(rtl::OString("%F4%8F%BF%BF")) == sal_True);
61cdf0e10cSrcweir         }
62cdf0e10cSrcweir 
insertUtf32_002()63cdf0e10cSrcweir     void insertUtf32_002()
64cdf0e10cSrcweir         {
65cdf0e10cSrcweir             ::rtl::OUStringBuffer aUStrBuf(4);
66cdf0e10cSrcweir             aUStrBuf.insertUtf32(0,0x41);
67cdf0e10cSrcweir             aUStrBuf.insertUtf32(1,0x42);
68cdf0e10cSrcweir             aUStrBuf.insertUtf32(2,0x43);
69cdf0e10cSrcweir 
70cdf0e10cSrcweir             rtl::OUString suStr = aUStrBuf.makeStringAndClear();
71cdf0e10cSrcweir             rtl::OUString suStr2 = rtl::Uri::encode(suStr, rtl_UriCharClassUnoParamValue, rtl_UriEncodeKeepEscapes, RTL_TEXTENCODING_UTF8);
72cdf0e10cSrcweir 
73cdf0e10cSrcweir             rtl::OString sStr;
74cdf0e10cSrcweir             sStr <<= suStr2;
75cdf0e10cSrcweir             t_print("%s\n", sStr.getStr());
76cdf0e10cSrcweir 
77cdf0e10cSrcweir             CPPUNIT_ASSERT_MESSAGE("Strings must be 'ABC'", sStr.equals(rtl::OString("ABC")) == sal_True);
78cdf0e10cSrcweir         }
79cdf0e10cSrcweir 
80cdf0e10cSrcweir     CPPUNIT_TEST_SUITE(insertUtf32);
81cdf0e10cSrcweir     CPPUNIT_TEST(insertUtf32_001);
82cdf0e10cSrcweir     CPPUNIT_TEST(insertUtf32_002);
83cdf0e10cSrcweir     CPPUNIT_TEST_SUITE_END();
84cdf0e10cSrcweir }; // class getToken
85cdf0e10cSrcweir 
86cdf0e10cSrcweir // -----------------------------------------------------------------------------
87cdf0e10cSrcweir CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_OUStringBuffer::insertUtf32, "rtl_OUStringBuffer");
88cdf0e10cSrcweir 
89cdf0e10cSrcweir } // namespace rtl_OUStringBuffer
90cdf0e10cSrcweir 
91cdf0e10cSrcweir 
92cdf0e10cSrcweir // -----------------------------------------------------------------------------
93cdf0e10cSrcweir 
94cdf0e10cSrcweir // this macro creates an empty function, which will called by the RegisterAllFunctions()
95cdf0e10cSrcweir // to let the user the possibility to also register some functions by hand.
96cdf0e10cSrcweir NOADDITIONAL;
97cdf0e10cSrcweir 
98