LCOV - code coverage report
Current view: top level - sal/qa/rtl/strings - test_oustring_compare.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 27 27 100.0 %
Date: 2012-08-25 Functions: 10 10 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 102 206 49.5 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <sal/types.h>
      30                 :            : #include <cppunit/TestFixture.h>
      31                 :            : #include <cppunit/extensions/HelperMacros.h>
      32                 :            : #include "rtl/string.h"
      33                 :            : #include "rtl/ustring.hxx"
      34                 :            : 
      35                 :            : namespace test { namespace oustring {
      36                 :            : 
      37         [ -  + ]:         30 : class Compare: public CppUnit::TestFixture
      38                 :            : {
      39                 :            : private:
      40                 :            :     void equalsIgnoreAsciiCaseAscii();
      41                 :            : 
      42                 :            :     void compareToAscii();
      43                 :            : 
      44 [ +  - ][ +  - ]:         10 : CPPUNIT_TEST_SUITE(Compare);
         [ +  - ][ +  - ]
                 [ #  # ]
      45 [ +  - ][ +  - ]:          5 : CPPUNIT_TEST(equalsIgnoreAsciiCaseAscii);
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
      46 [ +  - ][ +  - ]:          5 : CPPUNIT_TEST(compareToAscii);
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
      47 [ +  - ][ +  - ]:         10 : CPPUNIT_TEST_SUITE_END();
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
      48                 :            : };
      49                 :            : 
      50                 :            : } }
      51                 :            : 
      52                 :          5 : CPPUNIT_TEST_SUITE_REGISTRATION(test::oustring::Compare);
      53                 :            : 
      54                 :          5 : void test::oustring::Compare::equalsIgnoreAsciiCaseAscii()
      55                 :            : {
      56 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT(!rtl::OUString().equalsIgnoreAsciiCaseAscii("abc"));
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
      57 [ +  - ][ +  - ]:         10 :     CPPUNIT_ASSERT(!rtl::OUString().equalsIgnoreAsciiCaseAsciiL(
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
      58         [ +  - ]:          5 :                        RTL_CONSTASCII_STRINGPARAM("abc")));
      59 [ +  - ][ +  - ]:         10 :     CPPUNIT_ASSERT(!rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("abc")).
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
      60         [ +  - ]:          5 :                    equalsIgnoreAsciiCaseAscii(""));
      61 [ +  - ][ +  - ]:         10 :     CPPUNIT_ASSERT(!rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("abc")).
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
      62         [ +  - ]:          5 :                    equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("")));
      63                 :            : 
      64 [ +  - ][ +  - ]:         10 :     CPPUNIT_ASSERT(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("abc")).
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
      65         [ +  - ]:          5 :                    equalsIgnoreAsciiCaseAscii("abc"));
      66 [ +  - ][ +  - ]:         10 :     CPPUNIT_ASSERT(!rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("abcd")).
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
      67         [ +  - ]:          5 :                    equalsIgnoreAsciiCaseAscii("abc"));
      68 [ +  - ][ +  - ]:         10 :     CPPUNIT_ASSERT(!rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("abc")).
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
      69         [ +  - ]:          5 :                    equalsIgnoreAsciiCaseAscii("abcd"));
      70                 :          5 : }
      71                 :            : 
      72                 :          5 : void test::oustring::Compare::compareToAscii()
      73                 :            : {
      74                 :            :     // The different overloads of compareToAscii exhibit potentially confusing
      75                 :            :     // behavior:
      76                 :          5 :     rtl::OUString abc("abc");
      77 [ +  - ][ +  - ]:          5 :     CPPUNIT_ASSERT(abc.compareToAscii("a") > 0);
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
      78 [ +  - ][ +  - ]:         10 :     CPPUNIT_ASSERT_EQUAL(
         [ +  - ][ +  - ]
      79         [ +  - ]:         10 :         sal_Int32(0), abc.compareToAscii(RTL_CONSTASCII_STRINGPARAM("a")));
      80 [ +  - ][ +  - ]:         20 : }
      81                 :            : 
      82                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10