1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
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.
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).
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.
26 ************************************************************************/
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>
36 namespace rtl_OUStringBuffer
40 class insertUtf32
: public CppUnit::TestFixture
43 // initialise your test code values here.
52 void insertUtf32_001()
54 ::rtl::OUStringBuffer
aUStrBuf(4);
55 aUStrBuf
.insertUtf32(0,0x10ffff);
57 rtl::OUString suStr
= aUStrBuf
.makeStringAndClear();
58 rtl::OUString suStr2
= rtl::Uri::encode(suStr
, rtl_UriCharClassUnoParamValue
, rtl_UriEncodeKeepEscapes
, RTL_TEXTENCODING_UTF8
);
62 t_print("%s\n", sStr
.getStr());
64 CPPUNIT_ASSERT_MESSAGE("Strings must be '%F4%8F%BF%BF'", sStr
.equals(rtl::OString("%F4%8F%BF%BF")) == sal_True
);
67 void insertUtf32_002()
69 ::rtl::OUStringBuffer
aUStrBuf(4);
70 aUStrBuf
.insertUtf32(0,0x41);
71 aUStrBuf
.insertUtf32(1,0x42);
72 aUStrBuf
.insertUtf32(2,0x43);
74 rtl::OUString suStr
= aUStrBuf
.makeStringAndClear();
75 rtl::OUString suStr2
= rtl::Uri::encode(suStr
, rtl_UriCharClassUnoParamValue
, rtl_UriEncodeKeepEscapes
, RTL_TEXTENCODING_UTF8
);
79 t_print("%s\n", sStr
.getStr());
81 CPPUNIT_ASSERT_MESSAGE("Strings must be 'ABC'", sStr
.equals(rtl::OString("ABC")) == sal_True
);
84 CPPUNIT_TEST_SUITE(insertUtf32
);
85 CPPUNIT_TEST(insertUtf32_001
);
86 CPPUNIT_TEST(insertUtf32_002
);
87 CPPUNIT_TEST_SUITE_END();
90 // -----------------------------------------------------------------------------
91 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_OUStringBuffer::insertUtf32
, "rtl_OUStringBuffer");
93 } // namespace rtl_OUStringBuffer
96 // -----------------------------------------------------------------------------
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.