summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMårten Nordheim <marten.nordheim@qt.io>2021-04-29 12:36:12 +0200
committerMårten Nordheim <marten.nordheim@qt.io>2021-05-20 17:02:38 +0200
commita5dc381b4c987d933f1207035e275cdc24669de6 (patch)
tree2c79e8c6e1488b3df246e1c7720c831ae8620a85 /tests
parente8297ba17602475e0fc94e3a67a625dc5bc8c136 (diff)
QByteArrayView: add compare
There was previously no way to compare QByteArrayView to with another QByteArrayView case-insensitively without allocating memory. [ChangeLog][QtCore][QByteArrayView] Added compare(), enabling case sensitive and insensitive comparison with other QByteArrayViews. Change-Id: I7582cc414563ddbde26da35a568421edcc649f93 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/text/qbytearrayview/tst_qbytearrayview.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/auto/corelib/text/qbytearrayview/tst_qbytearrayview.cpp b/tests/auto/corelib/text/qbytearrayview/tst_qbytearrayview.cpp
index 35f883068d..d65731fdbd 100644
--- a/tests/auto/corelib/text/qbytearrayview/tst_qbytearrayview.cpp
+++ b/tests/auto/corelib/text/qbytearrayview/tst_qbytearrayview.cpp
@@ -193,6 +193,7 @@ private slots:
}
void comparison() const;
+ void compare() const;
private:
template <typename Data>
@@ -635,5 +636,19 @@ void tst_QByteArrayView::comparison() const
QVERIFY(bb > aa);
}
+void tst_QByteArrayView::compare() const
+{
+ QByteArrayView alpha = "original";
+
+ QVERIFY(alpha.compare("original", Qt::CaseSensitive) == 0);
+ QVERIFY(alpha.compare("Original", Qt::CaseSensitive) > 0);
+ QVERIFY(alpha.compare("Original", Qt::CaseInsensitive) == 0);
+ QByteArrayView beta = "unoriginal";
+ QVERIFY(alpha.compare(beta, Qt::CaseInsensitive) < 0);
+ beta = "Unoriginal";
+ QVERIFY(alpha.compare(beta, Qt::CaseInsensitive) < 0);
+ QVERIFY(alpha.compare(beta, Qt::CaseSensitive) > 0);
+}
+
QTEST_APPLESS_MAIN(tst_QByteArrayView)
#include "tst_qbytearrayview.moc"