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

Generated by: LCOV version 1.10