merge the formfield patch from ooo-build
[ooovba.git] / sal / qa / rtl / oustringbuffer / rtl_OUStringBuffer2.cxx
blob5d73b20517a81b5338480f8c747857348087900d
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: rtl_OUStringBuffer2.cxx,v $
10 * $Revision: 1.4 $
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
45 public:
46 // initialise your test code values here.
47 void setUp()
51 void tearDown()
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);
63 rtl::OString sStr;
64 sStr <<= suStr2;
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);
80 rtl::OString sStr;
81 sStr <<= suStr2;
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();
91 }; // class getToken
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.
103 NOADDITIONAL;