LCOV - code coverage report
Current view: top level - testtools/source/bridgetest - multi.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 55 66 83.3 %
Date: 2014-11-03 Functions: 4 7 57.1 %
Legend: Lines: hit not hit

          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             : 
      21             : #include "sal/config.h"
      22             : 
      23             : #include "multi.hxx"
      24             : 
      25             : #include "rtl/string.hxx"
      26             : #include "rtl/textenc.h"
      27             : #include "rtl/ustring.hxx"
      28             : 
      29             : #include <sstream>
      30             : 
      31             : namespace {
      32             : 
      33           0 : struct CheckFailed {
      34           0 :     explicit CheckFailed(OUString const & theMessage): message(theMessage)
      35           0 :     {}
      36             : 
      37             :     OUString message;
      38             : };
      39             : 
      40           0 : ::std::ostream& operator<< (::std::ostream& os, const OUString& str)
      41             : {
      42           0 :     return os << OUStringToOString(str, RTL_TEXTENCODING_UTF8).getStr();
      43             : }
      44             : 
      45         172 : template< typename T > void checkEqual(T const & value, T const & argument) {
      46         172 :     if (argument != value) {
      47           0 :         std::ostringstream s;
      48           0 :         s << value << " != " << argument;
      49           0 :         throw CheckFailed(
      50             :             OStringToOUString(
      51           0 :                 OString(s.str().c_str()), RTL_TEXTENCODING_UTF8));
      52             :     }
      53         172 : }
      54             : 
      55             : }
      56             : 
      57             : namespace testtools { namespace bridgetest {
      58             : 
      59           4 : OUString testMulti(
      60             :     com::sun::star::uno::Reference< test::testtools::bridgetest::XMulti >
      61             :     const & multi)
      62             : {
      63             :     try {
      64             :         checkEqual(
      65             :             0.0,
      66             :             css::uno::Reference< test::testtools::bridgetest::XMultiBase1 >(
      67           4 :                 multi, css::uno::UNO_QUERY_THROW)->getatt1());
      68             :         checkEqual(
      69             :             0.0,
      70             :             static_cast< test::testtools::bridgetest::XMultiBase2 * >(
      71           4 :                 multi.get())->getatt1());
      72             :         checkEqual(
      73             :             0.0,
      74             :             css::uno::Reference< test::testtools::bridgetest::XMultiBase2 >(
      75           4 :                 multi, css::uno::UNO_QUERY_THROW)->getatt1());
      76             :         checkEqual(
      77             :             0.0,
      78             :             static_cast< test::testtools::bridgetest::XMultiBase5 * >(
      79           4 :                 multi.get())->getatt1());
      80             :         checkEqual(
      81             :             0.0,
      82             :             css::uno::Reference< test::testtools::bridgetest::XMultiBase5 >(
      83           4 :                 multi, css::uno::UNO_QUERY_THROW)->getatt1());
      84             :         css::uno::Reference< test::testtools::bridgetest::XMultiBase5 >(
      85           4 :             multi, css::uno::UNO_QUERY_THROW)->setatt1(0.1);
      86             :         checkEqual(
      87             :             0.1,
      88             :             css::uno::Reference< test::testtools::bridgetest::XMultiBase1 >(
      89           4 :                 multi, css::uno::UNO_QUERY_THROW)->getatt1());
      90             :         checkEqual(
      91             :             0.1,
      92             :             static_cast< test::testtools::bridgetest::XMultiBase2 * >(
      93           4 :                 multi.get())->getatt1());
      94             :         checkEqual(
      95             :             0.1,
      96             :             css::uno::Reference< test::testtools::bridgetest::XMultiBase2 >(
      97           4 :                 multi, css::uno::UNO_QUERY_THROW)->getatt1());
      98             :         checkEqual(
      99             :             0.1,
     100             :             static_cast< test::testtools::bridgetest::XMultiBase5 * >(
     101           4 :                 multi.get())->getatt1());
     102             :         checkEqual(
     103             :             0.1,
     104             :             css::uno::Reference< test::testtools::bridgetest::XMultiBase5 >(
     105           4 :                 multi, css::uno::UNO_QUERY_THROW)->getatt1());
     106             :         checkEqual< sal_Int32 >(
     107             :             11 * 1,
     108             :             css::uno::Reference< test::testtools::bridgetest::XMultiBase1 >(
     109           4 :                 multi, css::uno::UNO_QUERY_THROW)->fn11(1));
     110             :         checkEqual< sal_Int32 >(
     111             :             11 * 1,
     112             :             static_cast< test::testtools::bridgetest::XMultiBase2 * >(
     113           4 :                 multi.get())->fn11(1));
     114             :         checkEqual< sal_Int32 >(
     115             :             11 * 2,
     116             :             css::uno::Reference< test::testtools::bridgetest::XMultiBase2 >(
     117           4 :                 multi, css::uno::UNO_QUERY_THROW)->fn11(2));
     118             :         checkEqual< sal_Int32 >(
     119             :             11 * 1,
     120             :             static_cast< test::testtools::bridgetest::XMultiBase5 * >(
     121           4 :                 multi.get())->fn11(1));
     122             :         checkEqual< sal_Int32 >(
     123             :             11 * 5,
     124             :             css::uno::Reference< test::testtools::bridgetest::XMultiBase5 >(
     125           4 :                 multi, css::uno::UNO_QUERY_THROW)->fn11(5));
     126             :         checkEqual(
     127             :             OUString("12" "abc"),
     128             :             css::uno::Reference< test::testtools::bridgetest::XMultiBase1 >(
     129           8 :                 multi, css::uno::UNO_QUERY_THROW)->fn12(
     130           4 :                     OUString("abc")));
     131             :         checkEqual(
     132             :             OUString("12" "abc-2"),
     133             :             static_cast< test::testtools::bridgetest::XMultiBase2 * >(
     134           4 :                 multi.get())->fn12(OUString("abc-2")));
     135             :         checkEqual(
     136             :             OUString("12" "abc-2"),
     137             :             css::uno::Reference< test::testtools::bridgetest::XMultiBase2 >(
     138           8 :                 multi, css::uno::UNO_QUERY_THROW)->fn12(
     139           4 :                     OUString("abc-2")));
     140             :         checkEqual(
     141             :             OUString("12" "abc-5"),
     142             :             static_cast< test::testtools::bridgetest::XMultiBase5 * >(
     143           4 :                 multi.get())->fn12(OUString("abc-5")));
     144             :         checkEqual(
     145             :             OUString("12" "abc-5"),
     146             :             css::uno::Reference< test::testtools::bridgetest::XMultiBase5 >(
     147           8 :                 multi, css::uno::UNO_QUERY_THROW)->fn12(
     148           4 :                     OUString("abc-5")));
     149           4 :         checkEqual< sal_Int32 >(21 * 2, multi->fn21(2));
     150             :         checkEqual(
     151             :             OUString("22" "de"),
     152           4 :             multi->fn22(OUString("de")));
     153             :         checkEqual< sal_Int32 >(
     154             :             31 * 3,
     155             :             css::uno::Reference< test::testtools::bridgetest::XMultiBase3 >(
     156           4 :                 multi, css::uno::UNO_QUERY_THROW)->fn31(3));
     157             :         checkEqual< sal_Int32 >(
     158             :             31 * 5,
     159             :             static_cast< test::testtools::bridgetest::XMultiBase5 * >(
     160           4 :                 multi.get())->fn31(5));
     161             :         checkEqual< sal_Int32 >(
     162             :             31 * 5,
     163             :             css::uno::Reference< test::testtools::bridgetest::XMultiBase5 >(
     164           4 :                 multi, css::uno::UNO_QUERY_THROW)->fn31(5));
     165             :         checkEqual(
     166             :             0.0,
     167             :             css::uno::Reference< test::testtools::bridgetest::XMultiBase3 >(
     168           4 :                 multi, css::uno::UNO_QUERY_THROW)->getatt3());
     169             :         checkEqual(
     170             :             0.0,
     171             :             static_cast< test::testtools::bridgetest::XMultiBase5 * >(
     172           4 :                 multi.get())->getatt3());
     173             :         checkEqual(
     174             :             0.0,
     175             :             css::uno::Reference< test::testtools::bridgetest::XMultiBase5 >(
     176           4 :                 multi, css::uno::UNO_QUERY_THROW)->getatt3());
     177             :         css::uno::Reference< test::testtools::bridgetest::XMultiBase3 >(
     178           4 :             multi, css::uno::UNO_QUERY_THROW)->setatt3(0.3);
     179             :         checkEqual(
     180             :             0.3,
     181             :             css::uno::Reference< test::testtools::bridgetest::XMultiBase3 >(
     182           4 :                 multi, css::uno::UNO_QUERY_THROW)->getatt3());
     183             :         checkEqual(
     184             :             0.3,
     185             :             static_cast< test::testtools::bridgetest::XMultiBase5 * >(
     186           4 :                 multi.get())->getatt3());
     187             :         checkEqual(
     188             :             0.3,
     189             :             css::uno::Reference< test::testtools::bridgetest::XMultiBase5 >(
     190           4 :                 multi, css::uno::UNO_QUERY_THROW)->getatt3());
     191             :         checkEqual(
     192             :             OUString("32" "f"),
     193             :             css::uno::Reference< test::testtools::bridgetest::XMultiBase3 >(
     194           8 :                 multi, css::uno::UNO_QUERY_THROW)->fn32(
     195           4 :                     OUString("f")));
     196             :         checkEqual(
     197             :             OUString("32" "f-5"),
     198             :             static_cast< test::testtools::bridgetest::XMultiBase5 * >(
     199           4 :                 multi.get())->fn32(OUString("f-5")));
     200             :         checkEqual(
     201             :             OUString("32" "f-5"),
     202             :             css::uno::Reference< test::testtools::bridgetest::XMultiBase5 >(
     203           8 :                 multi, css::uno::UNO_QUERY_THROW)->fn32(
     204           4 :                     OUString("f-5")));
     205             :         checkEqual< sal_Int32 >(
     206             :             33,
     207             :             css::uno::Reference< test::testtools::bridgetest::XMultiBase3 >(
     208           4 :                 multi, css::uno::UNO_QUERY_THROW)->fn33());
     209             :         checkEqual< sal_Int32 >(
     210             :             33,
     211             :             static_cast< test::testtools::bridgetest::XMultiBase5 * >(
     212           4 :                 multi.get())->fn33());
     213             :         checkEqual< sal_Int32 >(
     214             :             33,
     215             :             css::uno::Reference< test::testtools::bridgetest::XMultiBase5 >(
     216           4 :                 multi, css::uno::UNO_QUERY_THROW)->fn33());
     217           4 :         checkEqual< sal_Int32 >(41 * 4, multi->fn41(4));
     218           4 :         checkEqual< sal_Int32 >(61 * 6, multi->fn61(6));
     219             :         checkEqual(
     220             :             OUString("62" ""),
     221           4 :             multi->fn62(OUString()));
     222           4 :         checkEqual< sal_Int32 >(71 * 7, multi->fn71(7));
     223             :         checkEqual(
     224             :             OUString("72" "g"),
     225           4 :             multi->fn72(OUString("g")));
     226           4 :         checkEqual< sal_Int32 >(73, multi->fn73());
     227           0 :     } catch (CheckFailed const & f) {
     228           0 :         return f.message;
     229             :     }
     230           4 :     return OUString();
     231             : }
     232             : 
     233             : } }
     234             : 
     235             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10