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
25 // MARKER(update_precomp.py): autogen include statement, do not remove
26 #include "precompiled_sal.hxx"
27 #include "gtest/gtest.h"
28 #include "stringhelper.hxx"
29 #include <rtl/ustrbuf.hxx>
30 #include <rtl/uri.hxx>
31
32 namespace rtl_OUStringBuffer
33 {
34
35
36 class insertUtf32 : public ::testing::Test
37 {
38 public:
39 // initialise your test code values here.
SetUp()40 void SetUp()
41 {
42 }
43
TearDown()44 void TearDown()
45 {
46 }
47 }; // class getToken
48
49 // -----------------------------------------------------------------------------
50
TEST_F(insertUtf32,insertUtf32_001)51 TEST_F(insertUtf32, insertUtf32_001)
52 {
53 ::rtl::OUStringBuffer aUStrBuf(4);
54 aUStrBuf.insertUtf32(0,0x10ffff);
55
56 rtl::OUString suStr = aUStrBuf.makeStringAndClear();
57 rtl::OUString suStr2 = rtl::Uri::encode(suStr, rtl_UriCharClassUnoParamValue, rtl_UriEncodeKeepEscapes, RTL_TEXTENCODING_UTF8);
58
59 rtl::OString sStr;
60 sStr <<= suStr2;
61 printf("%s\n", sStr.getStr());
62
63 ASSERT_TRUE(sStr.equals(rtl::OString("%F4%8F%BF%BF")) == sal_True)
64 << "Strings must be '%F4%8F%BF%BF'";
65 }
66
TEST_F(insertUtf32,insertUtf32_002)67 TEST_F(insertUtf32, 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 printf("%s\n", sStr.getStr());
80
81 ASSERT_TRUE(sStr.equals(rtl::OString("ABC")) == sal_True)
82 << "Strings must be 'ABC'";
83 }
84
85 } // namespace rtl_OUStringBuffer
86
main(int argc,char ** argv)87 int main(int argc, char **argv)
88 {
89 ::testing::InitGoogleTest(&argc, argv);
90 return RUN_ALL_TESTS();
91 }
92