Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
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"
31 :
32 : #include "../source/bridge.hxx"
33 : #include "../source/cache.hxx"
34 : #include "../source/readerstate.hxx"
35 : #include "../source/unmarshal.hxx"
36 :
37 : namespace {
38 :
39 6 : class Test: public CppUnit::TestFixture {
40 : private:
41 2 : CPPUNIT_TEST_SUITE(Test);
42 1 : CPPUNIT_TEST(testTypeOfBooleanSequence);
43 1 : CPPUNIT_TEST(testTypeOfVoidSequence);
44 5 : CPPUNIT_TEST_SUITE_END();
45 :
46 : void testTypeOfBooleanSequence();
47 :
48 : void testTypeOfVoidSequence();
49 : };
50 :
51 1 : void Test::testTypeOfBooleanSequence() {
52 1 : binaryurp::ReaderState state;
53 : css::uno::Sequence<sal_Int8> buf{
54 : static_cast<sal_Int8>(static_cast<sal_uInt8>(20 | 0x80)),
55 : // sequence type | cache flag
56 : static_cast<sal_Int8>(
57 : static_cast<sal_uInt8>(binaryurp::cache::ignore >> 8)),
58 : static_cast<sal_Int8>(
59 : static_cast<sal_uInt8>(binaryurp::cache::ignore & 0xFF)),
60 : RTL_CONSTASCII_LENGTH("[]boolean"),
61 2 : '[', ']', 'b', 'o', 'o', 'l', 'e', 'a', 'n' };
62 2 : binaryurp::Unmarshal m(rtl::Reference< binaryurp::Bridge >(), state, buf);
63 2 : css::uno::TypeDescription t(m.readType());
64 2 : CPPUNIT_ASSERT(
65 : t.equals(
66 : css::uno::TypeDescription(
67 1 : cppu::UnoType< css::uno::Sequence< bool > >::get())));
68 2 : m.done();
69 1 : }
70 :
71 1 : void Test::testTypeOfVoidSequence() {
72 1 : binaryurp::ReaderState state;
73 : css::uno::Sequence<sal_Int8> buf{
74 : static_cast<sal_Int8>(static_cast<sal_uInt8>(20 | 0x80)),
75 : // sequence type | cache flag
76 : static_cast<sal_Int8>(
77 : static_cast<sal_uInt8>(binaryurp::cache::ignore >> 8)),
78 : static_cast<sal_Int8>(
79 : static_cast<sal_uInt8>(binaryurp::cache::ignore & 0xFF)),
80 2 : RTL_CONSTASCII_LENGTH("[]void"), '[', ']', 'v', 'o', 'i', 'd' };
81 2 : binaryurp::Unmarshal m(rtl::Reference< binaryurp::Bridge >(), state, buf);
82 : try {
83 1 : m.readType();
84 0 : CPPUNIT_FAIL("exception expected");
85 2 : } catch (const css::io::IOException &) {}
86 1 : }
87 :
88 1 : CPPUNIT_TEST_SUITE_REGISTRATION(Test);
89 :
90 : }
91 :
92 4 : CPPUNIT_PLUGIN_IMPLEMENT();
93 :
94 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|