LCOV - code coverage report
Current view: top level - libreoffice/i18npool/qa/cppunit - test_ordinalsuffix.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 49 49 100.0 %
Date: 2012-12-17 Functions: 13 14 92.9 %
Legend: Lines: hit not hit

          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             : #include <algorithm>
      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>
      14             : 
      15             : using namespace com::sun::star;
      16             : 
      17          12 : class TestOrdinalSuffix : public test::BootstrapFixtureBase
      18             : {
      19             : private:
      20             :     uno::Reference<i18n::XOrdinalSuffix> m_xOrdinal;
      21             : 
      22             : public:
      23             :     virtual void setUp();
      24             :     virtual void tearDown();
      25             : 
      26             :     void testFrench();
      27             :     void testEnglish();
      28             : 
      29           4 :     CPPUNIT_TEST_SUITE(TestOrdinalSuffix);
      30           2 :     CPPUNIT_TEST(testFrench);
      31           2 :     CPPUNIT_TEST(testEnglish);
      32           4 :     CPPUNIT_TEST_SUITE_END();
      33             : };
      34             : 
      35           4 : void TestOrdinalSuffix::setUp()
      36             : {
      37           4 :     BootstrapFixtureBase::setUp();
      38           4 :     m_xOrdinal = uno::Reference< i18n::XOrdinalSuffix >(m_xSFactory->createInstance(
      39           4 :         "com.sun.star.i18n.OrdinalSuffix"), uno::UNO_QUERY_THROW);
      40           4 : }
      41             : 
      42           4 : void TestOrdinalSuffix::tearDown()
      43             : {
      44           4 :     m_xOrdinal.clear();
      45           4 :     BootstrapFixtureBase::tearDown();
      46           4 : }
      47             : 
      48           2 : void TestOrdinalSuffix::testFrench()
      49             : {
      50           2 :     lang::Locale aLocale("fr", "LU", "");
      51           2 :     uno::Sequence< OUString > aSuffixes;
      52             :     OUString *pStart, *pEnd, *pFind;
      53             : 
      54             :     //1er
      55           2 :     aSuffixes = m_xOrdinal->getOrdinalSuffix(1, aLocale);
      56           2 :     pStart = comphelper::stl_begin(aSuffixes);
      57           2 :     pEnd = comphelper::stl_end(aSuffixes);
      58           2 :     pFind = std::find(pStart, pEnd, OUString("er"));
      59           2 :     CPPUNIT_ASSERT(pFind != pEnd);
      60             : 
      61             :     //2e, 3e, etc.
      62           2 :     aSuffixes = m_xOrdinal->getOrdinalSuffix(2, aLocale);
      63           2 :     pStart = comphelper::stl_begin(aSuffixes);
      64           2 :     pEnd = comphelper::stl_end(aSuffixes);
      65           2 :     pFind = std::find(pStart, pEnd, OUString("e"));
      66           2 :     CPPUNIT_ASSERT(pFind != pEnd);
      67           2 : }
      68             : 
      69           2 : void TestOrdinalSuffix::testEnglish()
      70             : {
      71           2 :     lang::Locale aLocale("en", "US", "");
      72           2 :     uno::Sequence< OUString > aSuffixes;
      73             :     OUString *pStart, *pEnd, *pFind;
      74             : 
      75             :     //1st
      76           2 :     aSuffixes = m_xOrdinal->getOrdinalSuffix(1, aLocale);
      77           2 :     pStart = comphelper::stl_begin(aSuffixes);
      78           2 :     pEnd = comphelper::stl_end(aSuffixes);
      79           2 :     pFind = std::find(pStart, pEnd, OUString("st"));
      80           2 :     CPPUNIT_ASSERT(pFind != pEnd);
      81             : 
      82             :     //2nd
      83           2 :     aSuffixes = m_xOrdinal->getOrdinalSuffix(2, aLocale);
      84           2 :     pStart = comphelper::stl_begin(aSuffixes);
      85           2 :     pEnd = comphelper::stl_end(aSuffixes);
      86           2 :     pFind = std::find(pStart, pEnd, OUString("nd"));
      87           2 :     CPPUNIT_ASSERT(pFind != pEnd);
      88             : 
      89             :     //3rd
      90           2 :     aSuffixes = m_xOrdinal->getOrdinalSuffix(3, aLocale);
      91           2 :     pStart = comphelper::stl_begin(aSuffixes);
      92           2 :     pEnd = comphelper::stl_end(aSuffixes);
      93           2 :     pFind = std::find(pStart, pEnd, OUString("rd"));
      94           2 :     CPPUNIT_ASSERT(pFind != pEnd);
      95           2 : }
      96             : 
      97             : 
      98           2 : CPPUNIT_TEST_SUITE_REGISTRATION( TestOrdinalSuffix );
      99             : 
     100           8 : CPPUNIT_PLUGIN_IMPLEMENT();
     101             : 
     102             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10