summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2017-03-10 15:27:40 +0100
committerMarc Mutz <marc.mutz@kdab.com>2017-03-12 17:41:16 +0000
commit75f5e2bef2ab942f89d5d025ecd45ee4d18e3d57 (patch)
tree0b6da8d12aa9812b100f72cdd738c8be94a19254 /tests/auto
parent63a39927a098aeb60a03b77361502b5be7659f1d (diff)
Deprecate QString::null
It's a Qt 3 compatibility vehicle, and as such inherits the now-alien property to distinguish empty and null strings. Particularly worrisome is the following asymmetry: QString("") == QString::null // false QString("") == QString(QString::null) // true Instead of fixing this behavior, recognize that people might use it as a weird way to call isNull(), albeit one that once was idiomatic, and simply deprecate everything that deals with QString::null. [ChangeLog][QtCore][QString] QString::null is now deprecated. When used to construct a QString, use QString() instead. When used to compare to a QString, replace with QString::isNull(). Change-Id: I9f7e84a92522c75666da15f49324c500ae93af42 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/corelib/io/qfile/tst_qfile.cpp2
-rw-r--r--tests/auto/corelib/tools/qstring/tst_qstring.cpp4
-rw-r--r--tests/auto/network/access/qftp/tst_qftp.cpp2
-rw-r--r--tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp2
-rw-r--r--tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp4
-rw-r--r--tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp10
-rw-r--r--tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp2
-rw-r--r--tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp2
8 files changed, 14 insertions, 14 deletions
diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp
index 57e197aa83..3620043eb1 100644
--- a/tests/auto/corelib/io/qfile/tst_qfile.cpp
+++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp
@@ -1684,7 +1684,7 @@ void tst_QFile::isSequential()
void tst_QFile::encodeName()
{
- QCOMPARE(QFile::encodeName(QString::null), QByteArray());
+ QCOMPARE(QFile::encodeName(QString()), QByteArray());
}
void tst_QFile::truncate()
diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp
index 48e856f406..03436375dd 100644
--- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp
+++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp
@@ -3818,7 +3818,7 @@ void tst_QString::startsWith()
QVERIFY( !a.startsWith(QLatin1Char('x')) );
QVERIFY( !a.startsWith(QChar()) );
- a = QString::null;
+ a = QString();
QVERIFY( !a.startsWith("") );
QVERIFY( a.startsWith(QString::null) );
QVERIFY( !a.startsWith("ABC") );
@@ -3928,7 +3928,7 @@ void tst_QString::endsWith()
QVERIFY( a.endsWith(QLatin1String(0)) );
QVERIFY( !a.endsWith(QLatin1String("ABC")) );
- a = QString::null;
+ a = QString();
QVERIFY( !a.endsWith("") );
QVERIFY( a.endsWith(QString::null) );
QVERIFY( !a.endsWith("ABC") );
diff --git a/tests/auto/network/access/qftp/tst_qftp.cpp b/tests/auto/network/access/qftp/tst_qftp.cpp
index a13fa86405..a1c8399a26 100644
--- a/tests/auto/network/access/qftp/tst_qftp.cpp
+++ b/tests/auto/network/access/qftp/tst_qftp.cpp
@@ -124,7 +124,7 @@ protected slots:
private:
QFtp *newFtp();
void addCommand( QFtp::Command, int );
- bool fileExists( const QString &host, quint16 port, const QString &user, const QString &password, const QString &file, const QString &cdDir = QString::null );
+ bool fileExists( const QString &host, quint16 port, const QString &user, const QString &password, const QString &file, const QString &cdDir = QString() );
bool dirExists( const QString &host, quint16 port, const QString &user, const QString &password, const QString &cdDir, const QString &dirToCreate );
void renameInit( const QString &host, const QString &user, const QString &password, const QString &createFile );
diff --git a/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp
index 8126e72ad2..d7772f5c34 100644
--- a/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp
+++ b/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp
@@ -2191,7 +2191,7 @@ void tst_QSqlDatabase::sqlStatementUseIsNull_189093()
CHECK_DATABASE(db);
// select a record with NULL value
- QSqlQuery q(QString::null, db);
+ QSqlQuery q(QString(), db);
QVERIFY_SQL(q, exec("select * from " + qTableName("qtest", __FILE__, db) + " where id = 4"));
QVERIFY_SQL(q, next());
diff --git a/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp b/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp
index 62c75cadf3..9d0c939d84 100644
--- a/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp
+++ b/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp
@@ -701,14 +701,14 @@ void tst_QShortcut::disabledItems()
sendKeyEvents( Qt::CTRL+Qt::Key_M, 0 );
QCOMPARE( currentResult, NoResult );
if (over_330)
- QCOMPARE( sbText, QString::null );
+ QCOMPARE( sbText, QString() );
currentResult = NoResult;
sendKeyEvents( Qt::CTRL+Qt::Key_K, 0 );
sendKeyEvents( Qt::CTRL+Qt::Key_L, 0 );
QCOMPARE( currentResult, Slot1Triggered );
if (over_330)
- QCOMPARE( sbText, QString::null );
+ QCOMPARE( sbText, QString() );
#endif
clearAllShortcuts();
cut1 = 0;
diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
index 4c0ffdc77c..330ce3a836 100644
--- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
+++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
@@ -713,8 +713,8 @@ void tst_QLineEdit::clearInputMask()
{
QLineEdit *testWidget = ensureTestWidget();
testWidget->setInputMask("000.000.000.000");
- QVERIFY(testWidget->inputMask() != QString::null);
- testWidget->setInputMask(QString::null);
+ QVERIFY(!testWidget->inputMask().isNull());
+ testWidget->setInputMask(QString());
QCOMPARE(testWidget->inputMask(), QString());
}
@@ -2277,7 +2277,7 @@ void tst_QLineEdit::textChangedAndTextEdited()
changed_count = 0;
edited_count = 0;
- changed_string = QString::null;
+ changed_string.clear();
testWidget->setText("foo");
QCOMPARE(changed_count, 1);
@@ -2286,7 +2286,7 @@ void tst_QLineEdit::textChangedAndTextEdited()
changed_count = 0;
edited_count = 0;
- changed_string = QString::null;
+ changed_string.clear();
testWidget->setText("");
QCOMPARE(changed_count, 1);
@@ -3108,7 +3108,7 @@ void tst_QLineEdit::maxLengthAndInputMask()
QVERIFY(testWidget->inputMask().isNull());
testWidget->setMaxLength(10);
QCOMPARE(testWidget->maxLength(), 10);
- testWidget->setInputMask(QString::null);
+ testWidget->setInputMask(QString());
QVERIFY(testWidget->inputMask().isNull());
QCOMPARE(testWidget->maxLength(), 10);
}
diff --git a/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp b/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp
index 31bbcf9c7f..af0ad1a601 100644
--- a/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp
+++ b/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp
@@ -362,7 +362,7 @@ void tst_QPlainTextEdit::emptyAppend()
{
ed->appendPlainText("Blah");
QCOMPARE(blockCount(), 1);
- ed->appendPlainText(QString::null);
+ ed->appendPlainText(QString());
QCOMPARE(blockCount(), 2);
ed->appendPlainText(QString(" "));
QCOMPARE(blockCount(), 3);
diff --git a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp
index cecec48113..b9ea310d80 100644
--- a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp
+++ b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp
@@ -676,7 +676,7 @@ void tst_QTextEdit::emptyAppend()
{
ed->append("Blah");
QCOMPARE(blockCount(), 1);
- ed->append(QString::null);
+ ed->append(QString());
QCOMPARE(blockCount(), 2);
ed->append(QString(" "));
QCOMPARE(blockCount(), 3);