14#include <com/sun/star/beans/PropertyValue.hpp>
15#include <com/sun/star/sheet/XFunctionDescriptions.hpp>
16#include <com/sun/star/lang/IllegalArgumentException.hpp>
17#include <com/sun/star/uno/Reference.hxx>
19#include <cppunit/TestAssert.h>
29 uno::Reference<sheet::XFunctionDescriptions> xFD(
init(), UNO_QUERY_THROW);
31 const sal_Int32
nCount = xFD->getCount();
32 CPPUNIT_ASSERT_MESSAGE(
"No FunctionDescriptions available", 0 <
nCount);
35 std::random_device rd;
36 std::mt19937 gen(rd());
37 std::uniform_int_distribution<> distr(0,
nCount - 1);
38 int nNumber = distr(gen);
42 uno::Sequence<beans::PropertyValue> aProps1;
43 CPPUNIT_ASSERT(xFD->getByIndex(nNumber) >>= aProps1);
44 for (
const auto& aProp : std::as_const(aProps1))
46 if (aProp.Name ==
"Id")
47 aId1 = aProp.Value.get<sal_Int32>();
48 if (aProp.Name ==
"Name")
49 aName1 = aProp.Value.get<OUString>();
55 const uno::Sequence<beans::PropertyValue> aProps2 = xFD->getById(aId1);
56 CPPUNIT_ASSERT_MESSAGE(
"Received empty FunctionDescriptions from getById()",
57 aProps2.hasElements());
58 for (
const auto& aProp : aProps2)
60 if (aProp.Name ==
"Id")
61 aId2 = aProp.Value.get<sal_Int32>();
62 if (aProp.Name ==
"Name")
63 aName2 = aProp.Value.get<OUString>();
65 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Received wrong FunctionDescriptions (Id)", aId1, aId2);
66 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Received wrong FunctionDescriptions (Name)", aName1, aName2);
68 CPPUNIT_ASSERT_THROW_MESSAGE(
"No IllegalArgumentException thrown", xFD->getById(-1),
69 css::lang::IllegalArgumentException);
virtual css::uno::Reference< css::uno::XInterface > init()=0