LCOV - code coverage report
Current view: top level - sal/qa/rtl/strings - test_oustring_compare.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 31 31 100.0 %
Date: 2014-11-03 Functions: 10 10 100.0 %
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             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <sal/types.h>
      21             : #include <cppunit/TestFixture.h>
      22             : #include <cppunit/extensions/HelperMacros.h>
      23             : #include "rtl/string.h"
      24             : #include "rtl/ustring.hxx"
      25             : 
      26             : namespace test { namespace oustring {
      27             : 
      28          12 : class Compare: public CppUnit::TestFixture
      29             : {
      30             : private:
      31             :     void equalsIgnoreAsciiCaseAscii();
      32             : 
      33             :     void compareToIgnoreAsciiCase();
      34             : 
      35           4 : CPPUNIT_TEST_SUITE(Compare);
      36           2 : CPPUNIT_TEST(equalsIgnoreAsciiCaseAscii);
      37           2 : CPPUNIT_TEST(compareToIgnoreAsciiCase);
      38           4 : CPPUNIT_TEST_SUITE_END();
      39             : };
      40             : 
      41             : } }
      42             : 
      43           2 : CPPUNIT_TEST_SUITE_REGISTRATION(test::oustring::Compare);
      44             : 
      45           2 : void test::oustring::Compare::equalsIgnoreAsciiCaseAscii()
      46             : {
      47           2 :     const char* const abc = "abc";
      48           2 :     const char* const abcd = "abcd";
      49           2 :     const char* const empty = "";
      50           2 :     CPPUNIT_ASSERT(!rtl::OUString().equalsIgnoreAsciiCaseAscii(abc));
      51           2 :     CPPUNIT_ASSERT(!rtl::OUString().equalsIgnoreAsciiCaseAsciiL(abc,3));
      52           4 :     CPPUNIT_ASSERT(!rtl::OUString("abc").
      53           2 :                    equalsIgnoreAsciiCaseAscii(empty));
      54           4 :     CPPUNIT_ASSERT(!rtl::OUString("abc").
      55           2 :                    equalsIgnoreAsciiCaseAsciiL(empty,0));
      56             : 
      57           4 :     CPPUNIT_ASSERT(rtl::OUString("abc").
      58           2 :                    equalsIgnoreAsciiCaseAscii(abc));
      59           4 :     CPPUNIT_ASSERT(!rtl::OUString("abcd").
      60           2 :                    equalsIgnoreAsciiCaseAscii(abc));
      61           4 :     CPPUNIT_ASSERT(!rtl::OUString("abc").
      62           2 :                    equalsIgnoreAsciiCaseAscii(abcd));
      63           2 : }
      64             : 
      65           2 : void test::oustring::Compare::compareToIgnoreAsciiCase()
      66             : {
      67           4 :     CPPUNIT_ASSERT_EQUAL(
      68             :         sal_Int32(0),
      69           2 :         rtl::OUString("abc").compareToIgnoreAsciiCase(rtl::OUString("ABC")));
      70           4 :     CPPUNIT_ASSERT(
      71             :         rtl::OUString("ABC").compareToIgnoreAsciiCase(rtl::OUString("abcdef"))
      72           2 :         < 0);
      73           4 :     CPPUNIT_ASSERT(
      74           2 :         rtl::OUString("A").compareToIgnoreAsciiCase(rtl::OUString("_")) > 0);
      75           8 : }
      76             : 
      77             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10