summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/corelib/tools/qstring.cpp9
-rw-r--r--tests/auto/corelib/tools/qstring/tst_qstring.cpp8
2 files changed, 7 insertions, 10 deletions
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index 30f8948eec..80c8510fa4 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -423,10 +423,6 @@ static int ucstricmp(const QChar *a, const QChar *ae, const QChar *b, const QCha
{
if (a == b)
return (ae - be);
- if (a == 0)
- return be - b;
- if (b == 0)
- return a - ae;
const QChar *e = ae;
if (be - b < ae - a)
@@ -455,11 +451,6 @@ static int ucstricmp(const QChar *a, const QChar *ae, const QChar *b, const QCha
// Case-insensitive comparison between a Unicode string and a QLatin1String
static int ucstricmp(const QChar *a, const QChar *ae, const char *b, const char *be)
{
- if (!a)
- return be - b;
- if (!b)
- return a - ae;
-
auto e = ae;
if (be - b < ae - a)
e = a + (be - b);
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;