1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2011 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 ************************************************************************/
28 #include "sal/config.h"
30 #include "com/sun/star/io/IOException.hpp"
31 #include "com/sun/star/uno/Sequence.hxx"
32 #include "cppu/unotype.hxx"
33 #include "cppunit/TestAssert.h"
34 #include "cppunit/TestFixture.h"
35 #include "cppunit/extensions/HelperMacros.h"
36 #include "cppunit/plugin/TestPlugIn.h"
37 #include "rtl/ref.hxx"
38 #include "rtl/string.h"
39 #include "sal/types.h"
40 #include "typelib/typedescription.hxx"
42 #include "../source/bridge.hxx"
43 #include "../source/cache.hxx"
44 #include "../source/readerstate.hxx"
45 #include "../source/unmarshal.hxx"
49 namespace css
= com::sun::star
;
51 class Test
: public CppUnit::TestFixture
{
53 CPPUNIT_TEST_SUITE(Test
);
54 CPPUNIT_TEST(testTypeOfBooleanSequence
);
55 CPPUNIT_TEST(testTypeOfVoidSequence
);
56 CPPUNIT_TEST_SUITE_END();
58 void testTypeOfBooleanSequence();
60 void testTypeOfVoidSequence();
63 void Test::testTypeOfBooleanSequence() {
64 binaryurp::ReaderState state
;
65 css::uno::Sequence
< sal_Int8
> buf(13);
66 buf
[0] = static_cast< sal_Int8
>(20 | 0x80); // sequence type | cache flag
67 buf
[1] = static_cast< sal_Int8
>(binaryurp::cache::ignore
>> 8);
68 buf
[2] = static_cast< sal_Int8
>(binaryurp::cache::ignore
& 0xFF);
69 buf
[3] = RTL_CONSTASCII_LENGTH("[]boolean");
79 binaryurp::Unmarshal
m(rtl::Reference
< binaryurp::Bridge
>(), state
, buf
);
80 css::uno::TypeDescription
t(m
.readType());
83 css::uno::TypeDescription(
84 cppu::UnoType
< css::uno::Sequence
< bool > >::get())));
88 void Test::testTypeOfVoidSequence() {
89 binaryurp::ReaderState state
;
90 css::uno::Sequence
< sal_Int8
> buf(10);
91 buf
[0] = static_cast< sal_Int8
>(20 | 0x80); // sequence type | cache flag
92 buf
[1] = static_cast< sal_Int8
>(binaryurp::cache::ignore
>> 8);
93 buf
[2] = static_cast< sal_Int8
>(binaryurp::cache::ignore
& 0xFF);
94 buf
[3] = RTL_CONSTASCII_LENGTH("[]void");
101 binaryurp::Unmarshal
m(rtl::Reference
< binaryurp::Bridge
>(), state
, buf
);
104 CPPUNIT_FAIL("exception expected");
105 } catch (css::io::IOException
&) {}
108 CPPUNIT_TEST_SUITE_REGISTRATION(Test
);
112 CPPUNIT_PLUGIN_IMPLEMENT();