LCOV - code coverage report
Current view: top level - test/source/sheet - xcellrangedata.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 29 29 100.0 %
Date: 2012-08-25 Functions: 5 5 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 45 82 54.9 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*
       3                 :            :  * Version: MPL 1.1 / GPLv3+ / LGPLv3+
       4                 :            :  *
       5                 :            :  * The contents of this file are subject to the Mozilla Public License Version
       6                 :            :  * 1.1 (the "License"); you may not use this file except in compliance with
       7                 :            :  * the License or as specified alternatively below. You may obtain a copy of
       8                 :            :  * the License at http://www.mozilla.org/MPL/
       9                 :            :  *
      10                 :            :  * Software distributed under the License is distributed on an "AS IS" basis,
      11                 :            :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      12                 :            :  * for the specific language governing rights and limitations under the
      13                 :            :  * License.
      14                 :            :  *
      15                 :            :  * Major Contributor(s):
      16                 :            :  * Copyright (C) 2012 Markus Mohrhard <markus.mohrhard@googlemail.com> (initial developer)
      17                 :            :  *
      18                 :            :  * All Rights Reserved.
      19                 :            :  *
      20                 :            :  * For minor contributions see the git repository.
      21                 :            :  *
      22                 :            :  * Alternatively, the contents of this file may be used under the terms of
      23                 :            :  * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
      24                 :            :  * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
      25                 :            :  * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
      26                 :            :  * instead of those above.
      27                 :            :  */
      28                 :            : 
      29                 :            : #include <test/sheet/xcellrangedata.hxx>
      30                 :            : #include <com/sun/star/sheet/XCellRangeData.hpp>
      31                 :            : 
      32                 :            : #include "cppunit/extensions/HelperMacros.h"
      33                 :            : 
      34                 :            : using namespace com::sun::star::uno;
      35                 :            : 
      36                 :            : namespace apitest {
      37                 :            : 
      38                 :            : namespace {
      39                 :            : 
      40                 :          4 : void setValues(uno::Sequence< uno::Sequence < Any > >& rColRow, double nOffset)
      41                 :            : {
      42         [ +  + ]:         20 :     for (sal_Int32 i = 0; i < 4; ++i)
      43                 :            :     {
      44                 :         16 :         rColRow[i].realloc(4);
      45         [ +  + ]:         80 :         for (sal_Int32 j = 0; j < 4; ++j)
      46                 :            :         {
      47 [ +  - ][ +  - ]:         64 :             Any& aAny = rColRow[i][j];
      48                 :         64 :             double nValue = i + j + nOffset;
      49         [ +  - ]:         64 :             aAny <<= nValue;
      50                 :            :         }
      51                 :            :     }
      52                 :          4 : }
      53                 :            : 
      54                 :            : }
      55                 :            : 
      56                 :          2 : void XCellRangeData::testSetDataArray()
      57                 :            : {
      58 [ +  - ][ +  - ]:          2 :     uno::Reference< sheet::XCellRangeData > xCellRangeData( getXCellRangeData(), UNO_QUERY_THROW);
      59                 :            : 
      60         [ +  - ]:          2 :     uno::Sequence< uno::Sequence < Any > > aColRow;
      61         [ +  - ]:          2 :     aColRow.realloc(4);
      62         [ +  - ]:          2 :     setValues(aColRow, 1);
      63 [ +  - ][ +  - ]:          2 :     xCellRangeData->setDataArray(aColRow);
      64                 :            :     // need to check here for correct values
      65                 :            : 
      66                 :            :     // set old values
      67         [ +  - ]:          2 :     setValues(aColRow, 0);
      68 [ +  - ][ +  - ]:          2 :     xCellRangeData->setDataArray(aColRow);
                 [ +  - ]
      69                 :          2 : }
      70                 :            : 
      71                 :          2 : void XCellRangeData::testGetDataArray()
      72                 :            : {
      73 [ +  - ][ +  - ]:          2 :     uno::Reference< sheet::XCellRangeData > xCellRangeData( getXCellRangeData(), UNO_QUERY_THROW);
      74 [ +  - ][ +  - ]:          2 :     uno::Sequence< uno::Sequence < Any > > aColRow = xCellRangeData->getDataArray();
      75         [ +  + ]:         10 :     for ( sal_Int32 i = 0; i < aColRow.getLength(); ++i)
      76                 :            :     {
      77 [ +  - ][ +  + ]:         40 :         for ( sal_Int32 j = 0; j < aColRow[i].getLength(); ++j)
      78                 :            :         {
      79 [ +  - ][ +  - ]:         32 :             Any& aAny = aColRow[i][j];
      80                 :         32 :             double nValue = 0.0;
      81 [ +  - ][ +  - ]:         32 :             CPPUNIT_ASSERT( aAny >>= nValue);
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
      82 [ +  - ][ +  - ]:         32 :             CPPUNIT_ASSERT_DOUBLES_EQUAL(static_cast<double>(i+j), nValue, 0.000001);
         [ +  - ][ +  - ]
                 [ +  - ]
      83                 :            :         }
      84         [ +  - ]:          2 :     }
      85                 :          2 : }
      86                 :            : 
      87 [ +  - ][ +  - ]:         66 : }
      88                 :            : 
      89                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10