summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/tools/qoffsetstringarray/tst_qoffsetstringarray.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/corelib/tools/qoffsetstringarray/tst_qoffsetstringarray.cpp')
-rw-r--r--tests/auto/corelib/tools/qoffsetstringarray/tst_qoffsetstringarray.cpp50
1 files changed, 18 insertions, 32 deletions
diff --git a/tests/auto/corelib/tools/qoffsetstringarray/tst_qoffsetstringarray.cpp b/tests/auto/corelib/tools/qoffsetstringarray/tst_qoffsetstringarray.cpp
index 0130939b4e..dbb24e7af4 100644
--- a/tests/auto/corelib/tools/qoffsetstringarray/tst_qoffsetstringarray.cpp
+++ b/tests/auto/corelib/tools/qoffsetstringarray/tst_qoffsetstringarray.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 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$
-**
-****************************************************************************/
+// Copyright (C) 2018 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
@@ -38,6 +13,7 @@ class tst_QOffsetStringArray : public QObject
private slots:
void init();
void access();
+ void contains();
};
@@ -46,8 +22,7 @@ constexpr const auto messages = qOffsetStringArray(
"level - 1",
"level - 2",
"level - 3",
- "level - 4",
- ""
+ "level - 4"
);
constexpr const auto messages257 = qOffsetStringArray(
@@ -90,15 +65,15 @@ constexpr const auto messagesBigOffsets = qOffsetStringArray(
void tst_QOffsetStringArray::init()
{
- static_assert(messages.m_string.size() == 51);
+ static_assert(messages.m_string.size() == 50);
static_assert(messages.m_offsets.size() == 6);
static_assert(std::is_same_v<decltype(messages.m_offsets)::value_type, quint8>);
- static_assert(messages257.m_offsets.size() == 257);
+ static_assert(messages257.m_offsets.size() == 258);
static_assert(messages257.m_string.size() == 260);
static_assert(std::is_same_v<decltype(messages257.m_offsets)::value_type, quint16>);
- static_assert(messagesBigOffsets.m_offsets.size() == 4);
+ static_assert(messagesBigOffsets.m_offsets.size() == 5);
static_assert(messagesBigOffsets.m_string.size() == 364);
static_assert(std::is_same_v<decltype(messagesBigOffsets.m_offsets)::value_type, quint16>);
}
@@ -110,10 +85,21 @@ void tst_QOffsetStringArray::access()
QCOMPARE(messages[2], "level - 2");
QCOMPARE(messages[3], "level - 3");
QCOMPARE(messages[4], "level - 4");
+ // out of bounds returns empty strings:
QCOMPARE(messages[5], "");
QCOMPARE(messages[6], "");
}
+void tst_QOffsetStringArray::contains()
+{
+ QVERIFY(!messages.contains(""));
+ QVERIFY( messages.contains("level - 0"));
+ std::string l2 = "level - 2"; // make sure we don't compare pointer values
+ QVERIFY( messages.contains(l2));
+ QByteArray L4 = "Level - 4";
+ QVERIFY( messages.contains(L4, Qt::CaseInsensitive));
+ QVERIFY(!messages.contains(L4, Qt::CaseSensitive));
+}
QTEST_APPLESS_MAIN(tst_QOffsetStringArray)
#include "tst_qoffsetstringarray.moc"