bump product version to 4.1.6.2
[LibreOffice.git] / sal / qa / rtl / strings / test_oustring_compare.cxx
blob7f56546df9140ce92cdadf43edb4aba502c6fa8f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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"
26 namespace test { namespace oustring {
28 class Compare: public CppUnit::TestFixture
30 private:
31 void equalsIgnoreAsciiCaseAscii();
33 void compareToIgnoreAsciiCase();
35 CPPUNIT_TEST_SUITE(Compare);
36 CPPUNIT_TEST(equalsIgnoreAsciiCaseAscii);
37 CPPUNIT_TEST(compareToIgnoreAsciiCase);
38 CPPUNIT_TEST_SUITE_END();
41 } }
43 CPPUNIT_TEST_SUITE_REGISTRATION(test::oustring::Compare);
45 void test::oustring::Compare::equalsIgnoreAsciiCaseAscii()
47 CPPUNIT_ASSERT(!rtl::OUString().equalsIgnoreAsciiCaseAscii("abc"));
48 CPPUNIT_ASSERT(!rtl::OUString().equalsIgnoreAsciiCaseAsciiL(
49 RTL_CONSTASCII_STRINGPARAM("abc")));
50 CPPUNIT_ASSERT(!rtl::OUString("abc").
51 equalsIgnoreAsciiCaseAscii(""));
52 CPPUNIT_ASSERT(!rtl::OUString("abc").
53 equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("")));
55 CPPUNIT_ASSERT(rtl::OUString("abc").
56 equalsIgnoreAsciiCaseAscii("abc"));
57 CPPUNIT_ASSERT(!rtl::OUString("abcd").
58 equalsIgnoreAsciiCaseAscii("abc"));
59 CPPUNIT_ASSERT(!rtl::OUString("abc").
60 equalsIgnoreAsciiCaseAscii("abcd"));
63 void test::oustring::Compare::compareToIgnoreAsciiCase()
65 CPPUNIT_ASSERT_EQUAL(
66 sal_Int32(0),
67 rtl::OUString("abc").compareToIgnoreAsciiCase(rtl::OUString("ABC")));
68 CPPUNIT_ASSERT(
69 rtl::OUString("ABC").compareToIgnoreAsciiCase(rtl::OUString("abcdef"))
70 < 0);
71 CPPUNIT_ASSERT(
72 rtl::OUString("A").compareToIgnoreAsciiCase(rtl::OUString("_")) > 0);
75 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */