LCOV - code coverage report
Current view: top level - test/source/sheet - xcellrangedata.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 29 29 100.0 %
Date: 2014-11-03 Functions: 5 5 100.0 %
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             : 
      10             : #include <test/sheet/xcellrangedata.hxx>
      11             : #include <com/sun/star/sheet/XCellRangeData.hpp>
      12             : 
      13             : #include "cppunit/extensions/HelperMacros.h"
      14             : 
      15             : using namespace css;
      16             : using namespace css::uno;
      17             : 
      18             : namespace apitest {
      19             : 
      20             : namespace {
      21             : 
      22           4 : void setValues(uno::Sequence< uno::Sequence < Any > >& rColRow, double nOffset)
      23             : {
      24          20 :     for (sal_Int32 i = 0; i < 4; ++i)
      25             :     {
      26          16 :         rColRow[i].realloc(4);
      27          80 :         for (sal_Int32 j = 0; j < 4; ++j)
      28             :         {
      29          64 :             Any& aAny = rColRow[i][j];
      30          64 :             double nValue = i + j + nOffset;
      31          64 :             aAny <<= nValue;
      32             :         }
      33             :     }
      34           4 : }
      35             : 
      36             : }
      37             : 
      38           2 : void XCellRangeData::testSetDataArray()
      39             : {
      40           2 :     uno::Reference< sheet::XCellRangeData > xCellRangeData( getXCellRangeData(), UNO_QUERY_THROW);
      41             : 
      42           4 :     uno::Sequence< uno::Sequence < Any > > aColRow;
      43           2 :     aColRow.realloc(4);
      44           2 :     setValues(aColRow, 1);
      45           2 :     xCellRangeData->setDataArray(aColRow);
      46             :     // need to check here for correct values
      47             : 
      48             :     // set old values
      49           2 :     setValues(aColRow, 0);
      50           4 :     xCellRangeData->setDataArray(aColRow);
      51           2 : }
      52             : 
      53           2 : void XCellRangeData::testGetDataArray()
      54             : {
      55           2 :     uno::Reference< sheet::XCellRangeData > xCellRangeData( getXCellRangeData(), UNO_QUERY_THROW);
      56           4 :     uno::Sequence< uno::Sequence < Any > > aColRow = xCellRangeData->getDataArray();
      57          10 :     for ( sal_Int32 i = 0; i < aColRow.getLength(); ++i)
      58             :     {
      59          40 :         for ( sal_Int32 j = 0; j < aColRow[i].getLength(); ++j)
      60             :         {
      61          32 :             Any& aAny = aColRow[i][j];
      62          32 :             double nValue = 0.0;
      63          32 :             CPPUNIT_ASSERT( aAny >>= nValue);
      64          32 :             CPPUNIT_ASSERT_DOUBLES_EQUAL(static_cast<double>(i+j), nValue, 0.000001);
      65             :         }
      66           2 :     }
      67           2 : }
      68             : 
      69         144 : }
      70             : 
      71             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10