update emoji autocorrect entries from po-files
[LibreOffice.git] / i18npool / qa / cppunit / test_ordinalsuffix.cxx
blob85466e773564102452218a8dcfe675d3778d0e37
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/.
8 */
9 #include <algorithm>
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
18 private:
19 uno::Reference<i18n::XOrdinalSuffix> m_xOrdinal;
21 public:
22 virtual void setUp() SAL_OVERRIDE;
23 virtual void tearDown() SAL_OVERRIDE;
25 void testFrench();
26 void testEnglish();
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 = uno::Reference< i18n::XOrdinalSuffix >(m_xSFactory->createInstance(
38 "com.sun.star.i18n.OrdinalSuffix"), uno::UNO_QUERY_THROW);
41 void TestOrdinalSuffix::tearDown()
43 m_xOrdinal.clear();
44 BootstrapFixtureBase::tearDown();
47 void TestOrdinalSuffix::testFrench()
49 lang::Locale aLocale("fr", "LU", "");
50 uno::Sequence< OUString > aSuffixes;
51 OUString *pStart, *pEnd, *pFind;
53 //1er
54 aSuffixes = m_xOrdinal->getOrdinalSuffix(1, aLocale);
55 pStart = aSuffixes.begin();
56 pEnd = aSuffixes.end();
57 pFind = std::find(pStart, pEnd, OUString("er"));
58 CPPUNIT_ASSERT(pFind != pEnd);
60 //2e, 3e, etc.
61 aSuffixes = m_xOrdinal->getOrdinalSuffix(2, aLocale);
62 pStart = aSuffixes.begin();
63 pEnd = aSuffixes.end();
64 pFind = std::find(pStart, pEnd, OUString("e"));
65 CPPUNIT_ASSERT(pFind != pEnd);
68 void TestOrdinalSuffix::testEnglish()
70 lang::Locale aLocale("en", "US", "");
71 uno::Sequence< OUString > aSuffixes;
72 OUString *pStart, *pEnd, *pFind;
74 //1st
75 aSuffixes = m_xOrdinal->getOrdinalSuffix(1, aLocale);
76 pStart = aSuffixes.begin();
77 pEnd = aSuffixes.end();
78 pFind = std::find(pStart, pEnd, OUString("st"));
79 CPPUNIT_ASSERT(pFind != pEnd);
81 //2nd
82 aSuffixes = m_xOrdinal->getOrdinalSuffix(2, aLocale);
83 pStart = aSuffixes.begin();
84 pEnd = aSuffixes.end();
85 pFind = std::find(pStart, pEnd, OUString("nd"));
86 CPPUNIT_ASSERT(pFind != pEnd);
88 //3rd
89 aSuffixes = m_xOrdinal->getOrdinalSuffix(3, aLocale);
90 pStart = aSuffixes.begin();
91 pEnd = aSuffixes.end();
92 pFind = std::find(pStart, pEnd, OUString("rd"));
93 CPPUNIT_ASSERT(pFind != pEnd);
97 CPPUNIT_TEST_SUITE_REGISTRATION( TestOrdinalSuffix );
99 CPPUNIT_PLUGIN_IMPLEMENT();
101 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */