summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2015-09-10 12:19:52 +0200
committerStephan Bergmann <sbergman@redhat.com>2015-09-10 23:04:32 +0200
commit350b9e36afb764661266ec8850488c6b23471de3 (patch)
tree341dad3732eab82791c52380361e8be7ac8a095e /sal
parentf9a4123637366d925e79b52123cb11dce1bccf0f (diff)
Add OString::startsWithIgnoreAsciiCase
...analogous to the existing OUString::startsWihtIgnoreAsciiCase, to be used in the next commit Change-Id: Iad6989c16e1bda6b2b0a58e6c768f7852560bb00
Diffstat (limited to 'sal')
-rw-r--r--sal/CppunitTest_sal_rtl_strings.mk1
-rw-r--r--sal/qa/rtl/strings/test_ostring.cxx92
2 files changed, 93 insertions, 0 deletions
diff --git a/sal/CppunitTest_sal_rtl_strings.mk b/sal/CppunitTest_sal_rtl_strings.mk
index 3fdb66db7411..57c92f48d408 100644
--- a/sal/CppunitTest_sal_rtl_strings.mk
+++ b/sal/CppunitTest_sal_rtl_strings.mk
@@ -12,6 +12,7 @@ $(eval $(call gb_CppunitTest_CppunitTest,sal_rtl_strings))
$(eval $(call gb_CppunitTest_add_exception_objects,sal_rtl_strings,\
sal/qa/rtl/strings/test_strings_replace \
+ sal/qa/rtl/strings/test_ostring \
sal/qa/rtl/strings/test_ostring_concat \
sal/qa/rtl/strings/test_ostring_stringliterals \
sal/qa/rtl/strings/test_oustring_compare \
diff --git a/sal/qa/rtl/strings/test_ostring.cxx b/sal/qa/rtl/strings/test_ostring.cxx
new file mode 100644
index 000000000000..2929b78c5b3f
--- /dev/null
+++ b/sal/qa/rtl/strings/test_ostring.cxx
@@ -0,0 +1,92 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <sal/config.h>
+
+#include <cppunit/TestAssert.h>
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+#include <rtl/string.hxx>
+
+namespace {
+
+class Test: public CppUnit::TestFixture {
+private:
+ void testStartsWithIgnoreAsciiCase();
+
+ CPPUNIT_TEST_SUITE(Test);
+ CPPUNIT_TEST(testStartsWithIgnoreAsciiCase);
+ CPPUNIT_TEST_SUITE_END();
+};
+
+void Test::testStartsWithIgnoreAsciiCase() {
+ {
+ OString r;
+ CPPUNIT_ASSERT(OString().startsWithIgnoreAsciiCase(OString(), &r));
+ CPPUNIT_ASSERT(r.isEmpty());
+ }
+ {
+ OString r;
+ CPPUNIT_ASSERT(OString("foo").startsWithIgnoreAsciiCase(OString(), &r));
+ CPPUNIT_ASSERT_EQUAL(OString("foo"), r);
+ }
+ {
+ OString r;
+ CPPUNIT_ASSERT(
+ OString("foo").startsWithIgnoreAsciiCase(OString("F"), &r));
+ CPPUNIT_ASSERT_EQUAL(OString("oo"), r);
+ }
+ {
+ OString r("other");
+ CPPUNIT_ASSERT(
+ !OString("foo").startsWithIgnoreAsciiCase(OString("bar"), &r));
+ CPPUNIT_ASSERT_EQUAL(OString("other"), r);
+ }
+ {
+ OString r("other");
+ CPPUNIT_ASSERT(
+ !OString("foo").startsWithIgnoreAsciiCase(OString("foobar"), &r));
+ CPPUNIT_ASSERT_EQUAL(OString("other"), r);
+ }
+
+ {
+ OString r;
+ CPPUNIT_ASSERT(OString().startsWithIgnoreAsciiCase("", &r));
+ CPPUNIT_ASSERT(r.isEmpty());
+ }
+ {
+ OString r;
+ CPPUNIT_ASSERT(OString("foo").startsWithIgnoreAsciiCase("", &r));
+ CPPUNIT_ASSERT_EQUAL(OString("foo"), r);
+ }
+ {
+ OString r;
+ CPPUNIT_ASSERT(
+ OString("foo").startsWithIgnoreAsciiCase("F", &r));
+ CPPUNIT_ASSERT_EQUAL(OString("oo"), r);
+ }
+ {
+ OString r("other");
+ CPPUNIT_ASSERT(
+ !OString("foo").startsWithIgnoreAsciiCase("bar", &r));
+ CPPUNIT_ASSERT_EQUAL(OString("other"), r);
+ }
+ {
+ OString r("other");
+ CPPUNIT_ASSERT(
+ !OString("foo").startsWithIgnoreAsciiCase("foobar", &r));
+ CPPUNIT_ASSERT_EQUAL(OString("other"), r);
+ }
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(Test);
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */