1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "com/sun/star/io/IOException.hpp"
21 #include "com/sun/star/uno/Sequence.hxx"
22 #include "cppu/unotype.hxx"
23 #include "cppunit/TestAssert.h"
24 #include "cppunit/TestFixture.h"
25 #include "cppunit/extensions/HelperMacros.h"
26 #include "cppunit/plugin/TestPlugIn.h"
27 #include "rtl/ref.hxx"
28 #include "rtl/string.h"
29 #include "sal/types.h"
30 #include "typelib/typedescription.hxx"
32 #include "../source/bridge.hxx"
33 #include "../source/cache.hxx"
34 #include "../source/readerstate.hxx"
35 #include "../source/unmarshal.hxx"
39 class Test
: public CppUnit::TestFixture
{
41 CPPUNIT_TEST_SUITE(Test
);
42 CPPUNIT_TEST(testTypeOfBooleanSequence
);
43 CPPUNIT_TEST(testTypeOfVoidSequence
);
44 CPPUNIT_TEST_SUITE_END();
46 void testTypeOfBooleanSequence();
48 void testTypeOfVoidSequence();
51 void Test::testTypeOfBooleanSequence() {
52 binaryurp::ReaderState state
;
53 css::uno::Sequence
< sal_Int8
> buf(13);
54 buf
[0] = static_cast< sal_Int8
>(static_cast< sal_uInt8
>(20 | 0x80)); // sequence type | cache flag
55 buf
[1] = static_cast< sal_Int8
>(static_cast< sal_uInt8
>(binaryurp::cache::ignore
>> 8));
56 buf
[2] = static_cast< sal_Int8
>(static_cast< sal_uInt8
>(binaryurp::cache::ignore
& 0xFF));
57 buf
[3] = RTL_CONSTASCII_LENGTH("[]boolean");
67 binaryurp::Unmarshal
m(rtl::Reference
< binaryurp::Bridge
>(), state
, buf
);
68 css::uno::TypeDescription
t(m
.readType());
71 css::uno::TypeDescription(
72 cppu::UnoType
< css::uno::Sequence
< bool > >::get())));
76 void Test::testTypeOfVoidSequence() {
77 binaryurp::ReaderState state
;
78 css::uno::Sequence
< sal_Int8
> buf(10);
79 buf
[0] = static_cast< sal_Int8
>(static_cast< sal_uInt8
>(20 | 0x80)); // sequence type | cache flag
80 buf
[1] = static_cast< sal_Int8
>(static_cast< sal_uInt8
>(binaryurp::cache::ignore
>> 8));
81 buf
[2] = static_cast< sal_Int8
>(static_cast< sal_uInt8
>(binaryurp::cache::ignore
& 0xFF));
82 buf
[3] = RTL_CONSTASCII_LENGTH("[]void");
89 binaryurp::Unmarshal
m(rtl::Reference
< binaryurp::Bridge
>(), state
, buf
);
92 CPPUNIT_FAIL("exception expected");
93 } catch (const css::io::IOException
&) {}
96 CPPUNIT_TEST_SUITE_REGISTRATION(Test
);
100 CPPUNIT_PLUGIN_IMPLEMENT();
102 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */