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 "sal/config.h"
11 :
12 : #include "cppunit/TestAssert.h"
13 : #include "cppunit/TestFixture.h"
14 : #include "cppunit/extensions/HelperMacros.h"
15 : #include "cppunit/plugin/TestPlugIn.h"
16 : #include "rtl/bootstrap.hxx"
17 : #include "rtl/ustring.hxx"
18 :
19 : namespace {
20 :
21 12 : class Test: public CppUnit::TestFixture {
22 : public:
23 : virtual void setUp() SAL_OVERRIDE;
24 :
25 : private:
26 4 : CPPUNIT_TEST_SUITE(Test);
27 2 : CPPUNIT_TEST(testDollar);
28 2 : CPPUNIT_TEST(testIndirectDollar);
29 4 : CPPUNIT_TEST_SUITE_END();
30 :
31 : void testDollar();
32 :
33 : void testIndirectDollar();
34 : };
35 :
36 4 : void Test::setUp() {
37 4 : rtl::Bootstrap::set("TEST", "<expanded TEST>");
38 4 : rtl::Bootstrap::set("WITH_DOLLAR", "foo\\$TEST");
39 4 : rtl::Bootstrap::set("INDIRECT", "$WITH_DOLLAR");
40 4 : }
41 :
42 2 : void Test::testDollar() {
43 2 : rtl::OUString s("$WITH_DOLLAR");
44 2 : rtl::Bootstrap::expandMacros(s);
45 2 : CPPUNIT_ASSERT_EQUAL(rtl::OUString("foo$TEST"), s);
46 2 : }
47 :
48 2 : void Test::testIndirectDollar() {
49 2 : rtl::OUString s("$INDIRECT");
50 2 : rtl::Bootstrap::expandMacros(s);
51 2 : CPPUNIT_ASSERT_EQUAL(rtl::OUString("foo$TEST"), s);
52 2 : }
53 :
54 2 : CPPUNIT_TEST_SUITE_REGISTRATION(Test);
55 :
56 : }
57 :
58 8 : CPPUNIT_PLUGIN_IMPLEMENT();
59 :
60 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|