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 <comphelper/stlunosequence.hxx>
13 #include <unotest/bootstrapfixturebase.hxx>
15 using namespace com::sun::star
;
17 class TestOrdinalSuffix
: public test::BootstrapFixtureBase
20 uno::Reference
<i18n::XOrdinalSuffix
> m_xOrdinal
;
24 virtual void tearDown();
29 CPPUNIT_TEST_SUITE(TestOrdinalSuffix
);
30 CPPUNIT_TEST(testFrench
);
31 CPPUNIT_TEST(testEnglish
);
32 CPPUNIT_TEST_SUITE_END();
35 void TestOrdinalSuffix::setUp()
37 BootstrapFixtureBase::setUp();
38 m_xOrdinal
= uno::Reference
< i18n::XOrdinalSuffix
>(m_xSFactory
->createInstance(
39 "com.sun.star.i18n.OrdinalSuffix"), uno::UNO_QUERY_THROW
);
42 void TestOrdinalSuffix::tearDown()
45 BootstrapFixtureBase::tearDown();
48 void TestOrdinalSuffix::testFrench()
50 lang::Locale
aLocale("fr", "LU", "");
51 uno::Sequence
< OUString
> aSuffixes
;
52 OUString
*pStart
, *pEnd
, *pFind
;
55 aSuffixes
= m_xOrdinal
->getOrdinalSuffix(1, aLocale
);
56 pStart
= comphelper::stl_begin(aSuffixes
);
57 pEnd
= comphelper::stl_end(aSuffixes
);
58 pFind
= std::find(pStart
, pEnd
, OUString("er"));
59 CPPUNIT_ASSERT(pFind
!= pEnd
);
62 aSuffixes
= m_xOrdinal
->getOrdinalSuffix(2, aLocale
);
63 pStart
= comphelper::stl_begin(aSuffixes
);
64 pEnd
= comphelper::stl_end(aSuffixes
);
65 pFind
= std::find(pStart
, pEnd
, OUString("e"));
66 CPPUNIT_ASSERT(pFind
!= pEnd
);
69 void TestOrdinalSuffix::testEnglish()
71 lang::Locale
aLocale("en", "US", "");
72 uno::Sequence
< OUString
> aSuffixes
;
73 OUString
*pStart
, *pEnd
, *pFind
;
76 aSuffixes
= m_xOrdinal
->getOrdinalSuffix(1, aLocale
);
77 pStart
= comphelper::stl_begin(aSuffixes
);
78 pEnd
= comphelper::stl_end(aSuffixes
);
79 pFind
= std::find(pStart
, pEnd
, OUString("st"));
80 CPPUNIT_ASSERT(pFind
!= pEnd
);
83 aSuffixes
= m_xOrdinal
->getOrdinalSuffix(2, aLocale
);
84 pStart
= comphelper::stl_begin(aSuffixes
);
85 pEnd
= comphelper::stl_end(aSuffixes
);
86 pFind
= std::find(pStart
, pEnd
, OUString("nd"));
87 CPPUNIT_ASSERT(pFind
!= pEnd
);
90 aSuffixes
= m_xOrdinal
->getOrdinalSuffix(3, aLocale
);
91 pStart
= comphelper::stl_begin(aSuffixes
);
92 pEnd
= comphelper::stl_end(aSuffixes
);
93 pFind
= std::find(pStart
, pEnd
, OUString("rd"));
94 CPPUNIT_ASSERT(pFind
!= pEnd
);
98 CPPUNIT_TEST_SUITE_REGISTRATION( TestOrdinalSuffix
);
100 CPPUNIT_PLUGIN_IMPLEMENT();
102 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */