summaryrefslogtreecommitdiff
path: root/i18npool/qa
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2012-09-06 10:09:32 +0100
committerCaolán McNamara <caolanm@redhat.com>2012-09-06 11:14:50 +0100
commitca00d27e33b187a9be36cad93bdaf662b5c221ea (patch)
treec56a33a8cdc0d1e671b804aed2624bd594206794 /i18npool/qa
parent5fc1d590e7e57b15eab64770880a52e44c5cca71 (diff)
Related: fdo#54486 add some regression tests for ordinal suffixes
Change-Id: Iea51d777c3cc1fdc58fa7fccfe01e4e8394e79b2
Diffstat (limited to 'i18npool/qa')
-rw-r--r--i18npool/qa/cppunit/test_breakiterator.cxx2
-rw-r--r--i18npool/qa/cppunit/test_ordinalsuffix.cxx102
2 files changed, 103 insertions, 1 deletions
diff --git a/i18npool/qa/cppunit/test_breakiterator.cxx b/i18npool/qa/cppunit/test_breakiterator.cxx
index 63f9708e708d..2073a9d30190 100644
--- a/i18npool/qa/cppunit/test_breakiterator.cxx
+++ b/i18npool/qa/cppunit/test_breakiterator.cxx
@@ -861,8 +861,8 @@ void TestBreakIterator::setUp()
void TestBreakIterator::tearDown()
{
- BootstrapFixtureBase::tearDown();
m_xBreak.clear();
+ BootstrapFixtureBase::tearDown();
}
CPPUNIT_TEST_SUITE_REGISTRATION(TestBreakIterator);
diff --git a/i18npool/qa/cppunit/test_ordinalsuffix.cxx b/i18npool/qa/cppunit/test_ordinalsuffix.cxx
new file mode 100644
index 000000000000..7b08aef44539
--- /dev/null
+++ b/i18npool/qa/cppunit/test_ordinalsuffix.cxx
@@ -0,0 +1,102 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+#include <algorithm>
+#include <com/sun/star/i18n/XOrdinalSuffix.hpp>
+#include <com/sun/star/lang/Locale.hpp>
+#include <comphelper/stlunosequence.hxx>
+#include <unotest/bootstrapfixturebase.hxx>
+
+using namespace com::sun::star;
+
+class TestOrdinalSuffix : public test::BootstrapFixtureBase
+{
+private:
+ uno::Reference<i18n::XOrdinalSuffix> m_xOrdinal;
+
+public:
+ virtual void setUp();
+ virtual void tearDown();
+
+ void testFrench();
+ void testEnglish();
+
+ CPPUNIT_TEST_SUITE(TestOrdinalSuffix);
+ CPPUNIT_TEST(testFrench);
+ CPPUNIT_TEST(testEnglish);
+ CPPUNIT_TEST_SUITE_END();
+};
+
+void TestOrdinalSuffix::setUp()
+{
+ BootstrapFixtureBase::setUp();
+ m_xOrdinal = uno::Reference< i18n::XOrdinalSuffix >(m_xSFactory->createInstance(
+ "com.sun.star.i18n.OrdinalSuffix"), uno::UNO_QUERY_THROW);
+}
+
+void TestOrdinalSuffix::tearDown()
+{
+ m_xOrdinal.clear();
+ BootstrapFixtureBase::tearDown();
+}
+
+void TestOrdinalSuffix::testFrench()
+{
+ lang::Locale aLocale("fr", "LU", "");
+ uno::Sequence< OUString > aSuffixes;
+ OUString *pStart, *pEnd, *pFind;
+
+ //1er
+ aSuffixes = m_xOrdinal->getOrdinalSuffix(1, aLocale);
+ pStart = comphelper::stl_begin(aSuffixes);
+ pEnd = comphelper::stl_end(aSuffixes);
+ pFind = std::find(pStart, pEnd, OUString("er"));
+ CPPUNIT_ASSERT(pFind != pEnd);
+
+ //2e, 3e, etc.
+ aSuffixes = m_xOrdinal->getOrdinalSuffix(2, aLocale);
+ pStart = comphelper::stl_begin(aSuffixes);
+ pEnd = comphelper::stl_end(aSuffixes);
+ pFind = std::find(pStart, pEnd, OUString("e"));
+ CPPUNIT_ASSERT(pFind != pEnd);
+}
+
+void TestOrdinalSuffix::testEnglish()
+{
+ lang::Locale aLocale("en", "US", "");
+ uno::Sequence< OUString > aSuffixes;
+ OUString *pStart, *pEnd, *pFind;
+
+ //1st
+ aSuffixes = m_xOrdinal->getOrdinalSuffix(1, aLocale);
+ pStart = comphelper::stl_begin(aSuffixes);
+ pEnd = comphelper::stl_end(aSuffixes);
+ pFind = std::find(pStart, pEnd, OUString("st"));
+ CPPUNIT_ASSERT(pFind != pEnd);
+
+ //2nd
+ aSuffixes = m_xOrdinal->getOrdinalSuffix(2, aLocale);
+ pStart = comphelper::stl_begin(aSuffixes);
+ pEnd = comphelper::stl_end(aSuffixes);
+ pFind = std::find(pStart, pEnd, OUString("nd"));
+ CPPUNIT_ASSERT(pFind != pEnd);
+
+ //3rd
+ aSuffixes = m_xOrdinal->getOrdinalSuffix(3, aLocale);
+ pStart = comphelper::stl_begin(aSuffixes);
+ pEnd = comphelper::stl_end(aSuffixes);
+ pFind = std::find(pStart, pEnd, OUString("rd"));
+ CPPUNIT_ASSERT(pFind != pEnd);
+}
+
+
+CPPUNIT_TEST_SUITE_REGISTRATION( TestOrdinalSuffix );
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */