1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <com/sun/star/i18n/XOrdinalSuffix.hpp>
11 #include <com/sun/star/lang/Locale.hpp>
12 #include <unotest/bootstrapfixturebase.hxx>
14 using namespace com::sun::star
;
16 class TestOrdinalSuffix
: public test::BootstrapFixtureBase
19 uno::Reference
<i18n::XOrdinalSuffix
> m_xOrdinal
;
22 virtual void setUp() override
;
23 virtual void tearDown() override
;
28 CPPUNIT_TEST_SUITE(TestOrdinalSuffix
);
29 CPPUNIT_TEST(testFrench
);
30 CPPUNIT_TEST(testEnglish
);
31 CPPUNIT_TEST_SUITE_END();
34 void TestOrdinalSuffix::setUp()
36 BootstrapFixtureBase::setUp();
37 m_xOrdinal
.set(m_xSFactory
->createInstance("com.sun.star.i18n.OrdinalSuffix"), uno::UNO_QUERY_THROW
);
40 void TestOrdinalSuffix::tearDown()
43 BootstrapFixtureBase::tearDown();
46 void TestOrdinalSuffix::testFrench()
48 lang::Locale
aLocale("fr", "LU", "");
49 uno::Sequence
< OUString
> aSuffixes
;
50 OUString
*pStart
, *pEnd
, *pFind
;
53 aSuffixes
= m_xOrdinal
->getOrdinalSuffix(1, aLocale
);
54 pStart
= aSuffixes
.begin();
55 pEnd
= aSuffixes
.end();
56 pFind
= std::find(pStart
, pEnd
, OUString("er"));
57 CPPUNIT_ASSERT(pFind
!= pEnd
);
60 aSuffixes
= m_xOrdinal
->getOrdinalSuffix(2, aLocale
);
61 pStart
= aSuffixes
.begin();
62 pEnd
= aSuffixes
.end();
63 pFind
= std::find(pStart
, pEnd
, OUString("e"));
64 CPPUNIT_ASSERT(pFind
!= pEnd
);
67 void TestOrdinalSuffix::testEnglish()
69 lang::Locale
aLocale("en", "US", "");
70 uno::Sequence
< OUString
> aSuffixes
;
71 OUString
*pStart
, *pEnd
, *pFind
;
74 aSuffixes
= m_xOrdinal
->getOrdinalSuffix(1, aLocale
);
75 pStart
= aSuffixes
.begin();
76 pEnd
= aSuffixes
.end();
77 pFind
= std::find(pStart
, pEnd
, OUString("st"));
78 CPPUNIT_ASSERT(pFind
!= pEnd
);
81 aSuffixes
= m_xOrdinal
->getOrdinalSuffix(2, aLocale
);
82 pStart
= aSuffixes
.begin();
83 pEnd
= aSuffixes
.end();
84 pFind
= std::find(pStart
, pEnd
, OUString("nd"));
85 CPPUNIT_ASSERT(pFind
!= pEnd
);
88 aSuffixes
= m_xOrdinal
->getOrdinalSuffix(3, aLocale
);
89 pStart
= aSuffixes
.begin();
90 pEnd
= aSuffixes
.end();
91 pFind
= std::find(pStart
, pEnd
, OUString("rd"));
92 CPPUNIT_ASSERT(pFind
!= pEnd
);
96 CPPUNIT_TEST_SUITE_REGISTRATION( TestOrdinalSuffix
);
98 CPPUNIT_PLUGIN_IMPLEMENT();
100 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */