1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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/.
10 #include <test/sheet/xsubtotalfield.hxx>
12 #include <com/sun/star/sheet/GeneralFunction.hpp>
13 #include <com/sun/star/sheet/SubTotalColumn.hpp>
14 #include <com/sun/star/sheet/XSubTotalField.hpp>
16 #include <com/sun/star/uno/Reference.hxx>
17 #include <com/sun/star/uno/Sequence.hxx>
19 #include <cppunit/TestAssert.h>
21 using namespace com::sun::star
;
22 using namespace com::sun::star::uno
;
26 template<> struct assertion_traits
<uno::Sequence
< sheet::SubTotalColumn
> >
28 static bool equal(const uno::Sequence
< sheet::SubTotalColumn
>& x
,
29 const uno::Sequence
< sheet::SubTotalColumn
>& y
)
34 static std::string
toString(const uno::Sequence
< sheet::SubTotalColumn
>& x
)
37 ost
<< "Sequence: Length: " << x
.getLength() << "\n";
38 for (const auto& rElement
: x
)
39 ost
<< "Column: " << rElement
.Column
<< " Function:\n";
40 // FIXME: Find a way to print Function
41 //ost << "Column: " << element->Column << " Function: " << element->Function << "\n";
50 void XSubTotalField::testGetSetGroupColumn()
52 uno::Reference
< sheet::XSubTotalField
> xSTF(init(), uno::UNO_QUERY_THROW
);
54 CPPUNIT_ASSERT_MESSAGE("Unable to get GroupColumn", xSTF
->getGroupColumn() != 0);
56 xSTF
->setGroupColumn(2);
57 CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set GroupColumn to new value",
58 sal_Int32(2), xSTF
->getGroupColumn());
61 void XSubTotalField::testGetSetTotalColumns()
63 uno::Reference
< sheet::XSubTotalField
> xSTF(init(), UNO_QUERY_THROW
);
65 uno::Sequence
< sheet::SubTotalColumn
> sDefaultCols
= xSTF
->getSubTotalColumns();
66 CPPUNIT_ASSERT_MESSAGE("Unable to get SubTotalColumns", sDefaultCols
.hasElements());
68 uno::Sequence
< sheet::SubTotalColumn
> sNewCols
;
70 sNewCols
[0].Column
= 5;
71 sNewCols
[0].Function
= sheet::GeneralFunction_AVERAGE
;
72 xSTF
->setSubTotalColumns(sNewCols
);
74 CPPUNIT_ASSERT_MESSAGE("Unable to set SubTotalColumns", sDefaultCols
!= xSTF
->getSubTotalColumns());
79 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */