1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: rtl_OUStringBuffer2.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
32 // MARKER(update_precomp.py): autogen include statement, do not remove
33 #include "precompiled_sal.hxx"
34 #include <cppunit/simpleheader.hxx>
35 #include "stringhelper.hxx"
36 #include <rtl/ustrbuf.hxx>
37 #include <rtl/uri.hxx>
39 namespace rtl_OUStringBuffer
43 class insertUtf32
: public CppUnit::TestFixture
46 // initialise your test code values here.
55 void insertUtf32_001()
57 ::rtl::OUStringBuffer
aUStrBuf(4);
58 aUStrBuf
.insertUtf32(0,0x10ffff);
60 rtl::OUString suStr
= aUStrBuf
.makeStringAndClear();
61 rtl::OUString suStr2
= rtl::Uri::encode(suStr
, rtl_UriCharClassUnoParamValue
, rtl_UriEncodeKeepEscapes
, RTL_TEXTENCODING_UTF8
);
65 t_print("%s\n", sStr
.getStr());
67 CPPUNIT_ASSERT_MESSAGE("Strings must be '%F4%8F%BF%BF'", sStr
.equals(rtl::OString("%F4%8F%BF%BF")) == sal_True
);
70 void insertUtf32_002()
72 ::rtl::OUStringBuffer
aUStrBuf(4);
73 aUStrBuf
.insertUtf32(0,0x41);
74 aUStrBuf
.insertUtf32(1,0x42);
75 aUStrBuf
.insertUtf32(2,0x43);
77 rtl::OUString suStr
= aUStrBuf
.makeStringAndClear();
78 rtl::OUString suStr2
= rtl::Uri::encode(suStr
, rtl_UriCharClassUnoParamValue
, rtl_UriEncodeKeepEscapes
, RTL_TEXTENCODING_UTF8
);
82 t_print("%s\n", sStr
.getStr());
84 CPPUNIT_ASSERT_MESSAGE("Strings must be 'ABC'", sStr
.equals(rtl::OString("ABC")) == sal_True
);
87 CPPUNIT_TEST_SUITE(insertUtf32
);
88 CPPUNIT_TEST(insertUtf32_001
);
89 CPPUNIT_TEST(insertUtf32_002
);
90 CPPUNIT_TEST_SUITE_END();
93 // -----------------------------------------------------------------------------
94 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_OUStringBuffer::insertUtf32
, "rtl_OUStringBuffer");
96 } // namespace rtl_OUStringBuffer
99 // -----------------------------------------------------------------------------
101 // this macro creates an empty function, which will called by the RegisterAllFunctions()
102 // to let the user the possibility to also register some functions by hand.