LCOV - code coverage report
Current view: top level - binaryurp/qa - test-unmarshal.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 47 47 100.0 %
Date: 2012-08-25 Functions: 11 12 91.7 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 77 174 44.3 %

           Branch data     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                 :            : namespace css = com::sun::star;
      40                 :            : 
      41         [ -  + ]:         18 : class Test: public CppUnit::TestFixture {
      42                 :            : private:
      43 [ +  - ][ +  - ]:          6 :     CPPUNIT_TEST_SUITE(Test);
         [ +  - ][ +  - ]
                 [ #  # ]
      44 [ +  - ][ +  - ]:          3 :     CPPUNIT_TEST(testTypeOfBooleanSequence);
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
      45 [ +  - ][ +  - ]:          3 :     CPPUNIT_TEST(testTypeOfVoidSequence);
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
      46 [ +  - ][ +  - ]:          6 :     CPPUNIT_TEST_SUITE_END();
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
      47                 :            : 
      48                 :            :     void testTypeOfBooleanSequence();
      49                 :            : 
      50                 :            :     void testTypeOfVoidSequence();
      51                 :            : };
      52                 :            : 
      53                 :          3 : void Test::testTypeOfBooleanSequence() {
      54                 :          3 :     binaryurp::ReaderState state;
      55         [ +  - ]:          3 :     css::uno::Sequence< sal_Int8 > buf(13);
      56         [ +  - ]:          3 :     buf[0] = static_cast< sal_Int8 >(static_cast< sal_uInt8 >(20 | 0x80)); // sequence type | cache flag
      57         [ +  - ]:          3 :     buf[1] = static_cast< sal_Int8 >(static_cast< sal_uInt8 >(binaryurp::cache::ignore >> 8));
      58         [ +  - ]:          3 :     buf[2] = static_cast< sal_Int8 >(static_cast< sal_uInt8 >(binaryurp::cache::ignore & 0xFF));
      59         [ +  - ]:          3 :     buf[3] = RTL_CONSTASCII_LENGTH("[]boolean");
      60         [ +  - ]:          3 :     buf[4] = '[';
      61         [ +  - ]:          3 :     buf[5] = ']';
      62         [ +  - ]:          3 :     buf[6] = 'b';
      63         [ +  - ]:          3 :     buf[7] = 'o';
      64         [ +  - ]:          3 :     buf[8] = 'o';
      65         [ +  - ]:          3 :     buf[9] = 'l';
      66         [ +  - ]:          3 :     buf[10] = 'e';
      67         [ +  - ]:          3 :     buf[11] = 'a';
      68         [ +  - ]:          3 :     buf[12] = 'n';
      69         [ +  - ]:          3 :     binaryurp::Unmarshal m(rtl::Reference< binaryurp::Bridge >(), state, buf);
      70         [ +  - ]:          3 :     css::uno::TypeDescription t(m.readType());
      71 [ +  - ][ +  - ]:          6 :     CPPUNIT_ASSERT(
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
      72                 :            :         t.equals(
      73                 :            :             css::uno::TypeDescription(
      74         [ +  - ]:          3 :                 cppu::UnoType< css::uno::Sequence< bool > >::get())));
      75 [ +  - ][ +  - ]:          3 :     m.done();
                 [ +  - ]
      76                 :          3 : }
      77                 :            : 
      78                 :          3 : void Test::testTypeOfVoidSequence() {
      79                 :          3 :     binaryurp::ReaderState state;
      80         [ +  - ]:          3 :     css::uno::Sequence< sal_Int8 > buf(10);
      81         [ +  - ]:          3 :     buf[0] = static_cast< sal_Int8 >(static_cast< sal_uInt8 >(20 | 0x80)); // sequence type | cache flag
      82         [ +  - ]:          3 :     buf[1] = static_cast< sal_Int8 >(static_cast< sal_uInt8 >(binaryurp::cache::ignore >> 8));
      83         [ +  - ]:          3 :     buf[2] = static_cast< sal_Int8 >(static_cast< sal_uInt8 >(binaryurp::cache::ignore & 0xFF));
      84         [ +  - ]:          3 :     buf[3] = RTL_CONSTASCII_LENGTH("[]void");
      85         [ +  - ]:          3 :     buf[4] = '[';
      86         [ +  - ]:          3 :     buf[5] = ']';
      87         [ +  - ]:          3 :     buf[6] = 'v';
      88         [ +  - ]:          3 :     buf[7] = 'o';
      89         [ +  - ]:          3 :     buf[8] = 'i';
      90         [ +  - ]:          3 :     buf[9] = 'd';
      91         [ +  - ]:          3 :     binaryurp::Unmarshal m(rtl::Reference< binaryurp::Bridge >(), state, buf);
      92                 :            :     try {
      93         [ -  + ]:          3 :         m.readType();
      94 [ #  # ][ #  # ]:          3 :         CPPUNIT_FAIL("exception expected");
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ -  + ]
                 [ #  # ]
      95 [ +  - ][ +  - ]:          3 :     } catch (const css::io::IOException &) {}
                 [ +  - ]
      96                 :          3 : }
      97                 :            : 
      98                 :          3 : CPPUNIT_TEST_SUITE_REGISTRATION(Test);
      99                 :            : 
     100                 :            : }
     101                 :            : 
     102 [ +  - ][ +  - ]:         12 : CPPUNIT_PLUGIN_IMPLEMENT();
         [ +  - ][ +  - ]
         [ +  - ][ #  # ]
     103                 :            : 
     104                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10