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/container/xnamecontainer.hxx>
11 : #include <com/sun/star/container/XNameContainer.hpp>
12 : #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
13 :
14 : #include "cppunit/extensions/HelperMacros.h"
15 : #include <iostream>
16 :
17 : using namespace css;
18 : using namespace css::uno;
19 :
20 : namespace apitest {
21 :
22 0 : XNameContainer::XNameContainer(): maNameToRemove("XNameContainer")
23 : {
24 0 : }
25 :
26 0 : XNameContainer::XNameContainer(const OUString& rNameToRemove):
27 0 : maNameToRemove(rNameToRemove)
28 : {
29 0 : }
30 :
31 0 : void XNameContainer::testRemoveByName()
32 : {
33 0 : uno::Reference< container::XNameContainer > xNameContainer(init(),UNO_QUERY_THROW);
34 0 : CPPUNIT_ASSERT(xNameContainer->hasByName(maNameToRemove));
35 0 : xNameContainer->removeByName(maNameToRemove);
36 0 : CPPUNIT_ASSERT(!xNameContainer->hasByName(maNameToRemove));
37 :
38 0 : bool bExceptionThrown = false;
39 : try
40 : {
41 0 : xNameContainer->removeByName(maNameToRemove);
42 : }
43 0 : catch( const container::NoSuchElementException& )
44 : {
45 0 : std::cout << "Exception Caught" << std::endl;
46 0 : bExceptionThrown = true;
47 : }
48 :
49 0 : CPPUNIT_ASSERT_MESSAGE("no exception thrown", bExceptionThrown);
50 0 : }
51 :
52 0 : }
53 :
54 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|