LCOV - code coverage report
Current view: top level - i18npool/qa/cppunit - test_ordinalsuffix.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 49 49 100.0 %
Date: 2015-06-13 12:38:46 Functions: 16 17 94.1 %
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 <unotest/bootstrapfixturebase.hxx>
      13             : 
      14             : using namespace com::sun::star;
      15             : 
      16           6 : class TestOrdinalSuffix : public test::BootstrapFixtureBase
      17             : {
      18             : private:
      19             :     uno::Reference<i18n::XOrdinalSuffix> m_xOrdinal;
      20             : 
      21             : public:
      22             :     virtual void setUp() SAL_OVERRIDE;
      23             :     virtual void tearDown() SAL_OVERRIDE;
      24             : 
      25             :     void testFrench();
      26             :     void testEnglish();
      27             : 
      28           2 :     CPPUNIT_TEST_SUITE(TestOrdinalSuffix);
      29           1 :     CPPUNIT_TEST(testFrench);
      30           1 :     CPPUNIT_TEST(testEnglish);
      31           5 :     CPPUNIT_TEST_SUITE_END();
      32             : };
      33             : 
      34           2 : void TestOrdinalSuffix::setUp()
      35             : {
      36           2 :     BootstrapFixtureBase::setUp();
      37           6 :     m_xOrdinal = uno::Reference< i18n::XOrdinalSuffix >(m_xSFactory->createInstance(
      38           4 :         "com.sun.star.i18n.OrdinalSuffix"), uno::UNO_QUERY_THROW);
      39           2 : }
      40             : 
      41           2 : void TestOrdinalSuffix::tearDown()
      42             : {
      43           2 :     m_xOrdinal.clear();
      44           2 :     BootstrapFixtureBase::tearDown();
      45           2 : }
      46             : 
      47           1 : void TestOrdinalSuffix::testFrench()
      48             : {
      49           1 :     lang::Locale aLocale("fr", "LU", "");
      50           2 :     uno::Sequence< OUString > aSuffixes;
      51             :     OUString *pStart, *pEnd, *pFind;
      52             : 
      53             :     //1er
      54           1 :     aSuffixes = m_xOrdinal->getOrdinalSuffix(1, aLocale);
      55           1 :     pStart = aSuffixes.begin();
      56           1 :     pEnd = aSuffixes.end();
      57           1 :     pFind = std::find(pStart, pEnd, OUString("er"));
      58           1 :     CPPUNIT_ASSERT(pFind != pEnd);
      59             : 
      60             :     //2e, 3e, etc.
      61           1 :     aSuffixes = m_xOrdinal->getOrdinalSuffix(2, aLocale);
      62           1 :     pStart = aSuffixes.begin();
      63           1 :     pEnd = aSuffixes.end();
      64           1 :     pFind = std::find(pStart, pEnd, OUString("e"));
      65           2 :     CPPUNIT_ASSERT(pFind != pEnd);
      66           1 : }
      67             : 
      68           1 : void TestOrdinalSuffix::testEnglish()
      69             : {
      70           1 :     lang::Locale aLocale("en", "US", "");
      71           2 :     uno::Sequence< OUString > aSuffixes;
      72             :     OUString *pStart, *pEnd, *pFind;
      73             : 
      74             :     //1st
      75           1 :     aSuffixes = m_xOrdinal->getOrdinalSuffix(1, aLocale);
      76           1 :     pStart = aSuffixes.begin();
      77           1 :     pEnd = aSuffixes.end();
      78           1 :     pFind = std::find(pStart, pEnd, OUString("st"));
      79           1 :     CPPUNIT_ASSERT(pFind != pEnd);
      80             : 
      81             :     //2nd
      82           1 :     aSuffixes = m_xOrdinal->getOrdinalSuffix(2, aLocale);
      83           1 :     pStart = aSuffixes.begin();
      84           1 :     pEnd = aSuffixes.end();
      85           1 :     pFind = std::find(pStart, pEnd, OUString("nd"));
      86           1 :     CPPUNIT_ASSERT(pFind != pEnd);
      87             : 
      88             :     //3rd
      89           1 :     aSuffixes = m_xOrdinal->getOrdinalSuffix(3, aLocale);
      90           1 :     pStart = aSuffixes.begin();
      91           1 :     pEnd = aSuffixes.end();
      92           1 :     pFind = std::find(pStart, pEnd, OUString("rd"));
      93           2 :     CPPUNIT_ASSERT(pFind != pEnd);
      94           1 : }
      95             : 
      96             : 
      97           1 : CPPUNIT_TEST_SUITE_REGISTRATION( TestOrdinalSuffix );
      98             : 
      99           4 : CPPUNIT_PLUGIN_IMPLEMENT();
     100             : 
     101             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11