summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2018-01-23 10:25:54 -0800
committerThiago Macieira <thiago.macieira@intel.com>2018-02-04 17:24:59 +0000
commitea6675374fa6e94bd4cf10613c85cee2c724bcdc (patch)
treecc6f71b928f679e378fe8f4601f40d211241bfa9 /tests/auto/corelib
parent15ae7949661c6d7f401c83af5bdbb63a2ec46a2a (diff)
QString: fix comparisons to null strings in ucstricmp
Commit 8f52ad9fe084eee26869e4a94a678076845a6f58 ("ucstricmp: compare null and empty strings equal") made sure empties and nulls would compare equally, but may have broken the null vs non-empty comparison (which was not tested). The commit message also said that it expected all callers to handle null before calling into those functions, but that's not the case for QStringView created from a null QString: the incoming "a" pointer was null. So just remove the checks for null pointers and rely on the size checks doing the right thing. [ChangeLog][QtCore][QString] Fixed a regression from 5.9 that caused comparing default-constructed QStrings to be sorted after non-empty strings. Task-number: QTBUG-65939 Change-Id: I56b444f9d6274221a3b7fffd150c83ad46c599b6 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'tests/auto/corelib')
-rw-r--r--tests/auto/corelib/tools/qstring/tst_qstring.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp
index 70ccc72630..a028391b06 100644
--- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp
+++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp
@@ -6043,8 +6043,14 @@ void tst_QString::compare_data()
QTest::addColumn<int>("csr"); // case sensitive result
QTest::addColumn<int>("cir"); // case insensitive result
-
// null strings
+ QTest::newRow("null-null") << QString() << QString() << 0 << 0;
+ QTest::newRow("text-null") << QString("a") << QString() << 1 << 1;
+ QTest::newRow("null-text") << QString() << QString("a") << -1 << -1;
+ QTest::newRow("null-empty") << QString() << QString("") << 0 << 0;
+ QTest::newRow("empty-null") << QString("") << QString() << 0 << 0;
+
+ // empty strings
QTest::newRow("data0") << QString("") << QString("") << 0 << 0;
QTest::newRow("data1") << QString("a") << QString("") << 1 << 1;
QTest::newRow("data2") << QString("") << QString("a") << -1 << -1;