nss: upgrade to release 3.73
[LibreOffice.git] / test / source / sheet / xcellrangedata.cxx
blob6bd8f0f8517173e9737744beb67b3c535ede69b1
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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 */
10 #include <test/sheet/xcellrangedata.hxx>
12 #include <com/sun/star/sheet/XCellRangeData.hpp>
13 #include <com/sun/star/uno/Any.hxx>
14 #include <com/sun/star/uno/Reference.hxx>
15 #include <com/sun/star/uno/RuntimeException.hpp>
16 #include <com/sun/star/uno/Sequence.hxx>
18 #include <cppunit/TestAssert.h>
20 using namespace css;
21 using namespace css::uno;
23 namespace apitest {
25 namespace {
27 void setValues(uno::Sequence< uno::Sequence < Any > >& rColRow, double nOffset)
29 for (sal_Int32 i = 0; i < 4; ++i)
31 rColRow[i].realloc(4);
32 for (sal_Int32 j = 0; j < 4; ++j)
34 Any& aAny = rColRow[i][j];
35 double nValue = i + j + nOffset;
36 aAny <<= nValue;
43 void XCellRangeData::testSetDataArray()
45 uno::Reference< sheet::XCellRangeData > xCellRangeData( getXCellRangeData(), UNO_QUERY_THROW);
47 uno::Sequence< uno::Sequence < Any > > aColRow;
48 aColRow.realloc(4);
49 setValues(aColRow, 1);
50 xCellRangeData->setDataArray(aColRow);
52 for ( sal_Int32 i = 0; i < aColRow.getLength(); ++i)
54 for ( sal_Int32 j = 0; j < aColRow[i].getLength(); ++j)
56 Any& aAny = aColRow[i][j];
57 double nValue = 0.0;
58 CPPUNIT_ASSERT( aAny >>= nValue);
59 CPPUNIT_ASSERT_DOUBLES_EQUAL(static_cast<double>(i+j+1), nValue, 0.000001);
63 // set old values
64 setValues(aColRow, 0);
65 xCellRangeData->setDataArray(aColRow);
68 void XCellRangeData::testGetDataArray()
70 uno::Reference< sheet::XCellRangeData > xCellRangeData( getXCellRangeData(), UNO_QUERY_THROW);
71 uno::Sequence< uno::Sequence < Any > > aColRow = xCellRangeData->getDataArray();
72 CPPUNIT_ASSERT(aColRow.hasElements());
75 void XCellRangeData::testGetDataArrayOnTableSheet()
77 uno::Reference< sheet::XCellRangeData > xCellRangeData( getXCellRangeData(), UNO_QUERY_THROW);
78 CPPUNIT_ASSERT_THROW_MESSAGE("No RuntimeException thrown", xCellRangeData->getDataArray(),
79 css::uno::RuntimeException);
82 void XCellRangeData::testSetDataArrayOnTableSheet()
84 uno::Reference< sheet::XCellRangeData > xCellRangeData( getXCellRangeData(), UNO_QUERY_THROW);
86 uno::Sequence< uno::Sequence < Any > > aColRow;
87 aColRow.realloc(4);
88 setValues(aColRow, 1);
89 CPPUNIT_ASSERT_THROW_MESSAGE("No RuntimeException thrown", xCellRangeData->setDataArray(aColRow),
90 css::uno::RuntimeException);
94 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */