summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/text/qstringmatcher/tst_qstringmatcher.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/corelib/text/qstringmatcher/tst_qstringmatcher.cpp')
-rw-r--r--tests/auto/corelib/text/qstringmatcher/tst_qstringmatcher.cpp62
1 files changed, 31 insertions, 31 deletions
diff --git a/tests/auto/corelib/text/qstringmatcher/tst_qstringmatcher.cpp b/tests/auto/corelib/text/qstringmatcher/tst_qstringmatcher.cpp
index 2d577bb0ab..c7f67f8541 100644
--- a/tests/auto/corelib/text/qstringmatcher/tst_qstringmatcher.cpp
+++ b/tests/auto/corelib/text/qstringmatcher/tst_qstringmatcher.cpp
@@ -1,32 +1,7 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtTest/QtTest>
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include <QTest>
#include <qstringmatcher.h>
class tst_QStringMatcher : public QObject
@@ -49,13 +24,14 @@ void tst_QStringMatcher::qstringmatcher()
QCOMPARE(matcher.caseSensitivity(), Qt::CaseSensitive);
QCOMPARE(matcher.indexIn("foo", 1), 1);
QCOMPARE(matcher.pattern(), QString());
+ QCOMPARE(matcher.patternView(), QStringView());
}
// public Qt::CaseSensitivity caseSensitivity() const
void tst_QStringMatcher::caseSensitivity()
{
const QString haystack = QStringLiteral("foobarFoo");
- const QStringRef needle = haystack.rightRef(3); // "Foo"
+ const QStringView needle = QStringView{ haystack }.right(3); // "Foo"
QStringMatcher matcher(needle.data(), needle.size());
QCOMPARE(matcher.caseSensitivity(), Qt::CaseSensitive);
@@ -117,7 +93,30 @@ void tst_QStringMatcher::setCaseSensitivity_data()
QTest::newRow("overshot") << QString("foo") << QString("baFooz foo bar") << 14 << -1 << (int) Qt::CaseSensitive;
QTest::newRow("sensitive") << QString("foo") << QString("baFooz foo bar") << 1 << 7 << (int) Qt::CaseSensitive;
- QTest::newRow("insensitive") << QString("foo") << QString("baFooz foo bar") << 1 << 2 << (int) Qt::CaseInsensitive;
+ QTest::newRow("insensitive-1")
+ << QString("foo") << QString("baFooz foo bar") << 0 << 2 << (int)Qt::CaseInsensitive;
+ QTest::newRow("insensitive-2")
+ << QString("foo") << QString("baFooz foo bar") << 1 << 2 << (int)Qt::CaseInsensitive;
+ QTest::newRow("insensitive-3")
+ << QString("foo") << QString("baFooz foo bar") << 4 << 7 << (int)Qt::CaseInsensitive;
+ QTest::newRow("insensitive-4")
+ << QString("foogabooga") << QString("baFooGaBooga foogabooga bar") << 1 << 2
+ << (int)Qt::CaseInsensitive;
+ QTest::newRow("insensitive-5")
+ << QString("foogabooga") << QString("baFooGaBooga foogabooga bar") << 3 << 13
+ << (int)Qt::CaseInsensitive;
+ QTest::newRow("insensitive-6") << QString("foogabooga") << QString("GaBoogaFoogaBooga bar") << 0
+ << 7 << (int)Qt::CaseInsensitive;
+ QTest::newRow("insensitive-7") << QString("foogabooga") << QString("FoGaBoogaFoogaBooga") << 9
+ << 9 << (int)Qt::CaseInsensitive;
+ QTest::newRow("insensitive-8") << QString("foogaBooga") << QString("zzzzaazzffoogaBooga") << 0
+ << 9 << (int)Qt::CaseInsensitive;
+ QString stringOf32("abcdefghijklmnopqrstuvwxyz123456");
+ Q_ASSERT(stringOf32.size() == 32);
+ QString stringOf128 = stringOf32 + stringOf32 + stringOf32 + stringOf32;
+ QString needle = stringOf128 + stringOf128 + "CAse";
+ QString haystack = stringOf128 + stringOf128 + "caSE";
+ QTest::newRow("insensitive-9") << needle << haystack << 0 << 0 << (int)Qt::CaseInsensitive;
}
void tst_QStringMatcher::setCaseSensitivity()
@@ -145,6 +144,7 @@ void tst_QStringMatcher::assignOperator()
QStringMatcher m2 = m1;
QCOMPARE(m2.pattern(), needle);
+ QCOMPARE(m2.patternView(), needle);
QCOMPARE(m2.indexIn(hayStack), 3);
}