LibreOffice Module test (master) 1
xtextrange.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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
11
12#include <com/sun/star/text/XText.hpp>
13#include <com/sun/star/text/XTextRange.hpp>
14
15#include <cppunit/TestAssert.h>
16
17using namespace css;
18
19namespace apitest
20{
22{
23 uno::Reference<text::XTextRange> xTextRange(init(), uno::UNO_QUERY_THROW);
24
25 xTextRange->setString("UnitTest");
26 uno::Reference<text::XTextRange> xTR_end(xTextRange->getEnd(), uno::UNO_SET_THROW);
27 xTR_end->setString("End");
28
29 CPPUNIT_ASSERT(xTextRange->getText()->getString().endsWith("End"));
30}
31
33{
34 uno::Reference<text::XTextRange> xTextRange(init(), uno::UNO_QUERY_THROW);
35
36 xTextRange->setString("UnitTest");
37 CPPUNIT_ASSERT_EQUAL(OUString("UnitTest"), xTextRange->getString());
38}
39
41{
42 uno::Reference<text::XTextRange> xTextRange(init(), uno::UNO_QUERY_THROW);
43
44 xTextRange->setString("UnitTest");
45 uno::Reference<text::XTextRange> xTR_start(xTextRange->getStart(), uno::UNO_SET_THROW);
46 xTR_start->setString("Start");
47
48 CPPUNIT_ASSERT(xTextRange->getText()->getString().startsWith("Start"));
49}
50
52{
53 uno::Reference<text::XTextRange> xTextRange(init(), uno::UNO_QUERY_THROW);
54
55 xTextRange->setString("UnitTest");
56 uno::Reference<text::XText> xText(xTextRange->getText(), uno::UNO_SET_THROW);
57 CPPUNIT_ASSERT_EQUAL(OUString("UnitTest"), xTextRange->getString());
58}
59} // namespace apitest
60
61/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
virtual css::uno::Reference< css::uno::XInterface > init()=0