From a8ff0bc887f192bd03cdd937972491059fbebf53 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sun, 13 Dec 2015 02:41:55 +0100 Subject: [PATCH] tst_QChar: add a check for comparing against int/uint This is used throughout Qt and resolves to operator op(QChar, QChar) This test makes sure we don't break those use-cases as we fix missing relational operators as found by tst_QStringBinOps. In the other direction, 0 op QChar is ambiguous, due to op(const char*, QString) etc, so only test the uint op QChar case. Change-Id: Ifae7fb65bf3269583898cfea3fc6c95547c75122 Reviewed-by: Olivier Goffart (Woboq GmbH) --- tests/auto/corelib/tools/qchar/tst_qchar.cpp | 25 ++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/auto/corelib/tools/qchar/tst_qchar.cpp b/tests/auto/corelib/tools/qchar/tst_qchar.cpp index 32002fe7edc..29e48a1cc8f 100644 --- a/tests/auto/corelib/tools/qchar/tst_qchar.cpp +++ b/tests/auto/corelib/tools/qchar/tst_qchar.cpp @@ -44,6 +44,7 @@ class tst_QChar : public QObject { Q_OBJECT private slots: + void operator_eqeq_int(); void operators_data(); void operators(); void toUpper(); @@ -79,6 +80,30 @@ private slots: void unicodeVersion(); }; +void tst_QChar::operator_eqeq_int() +{ + { + const QChar ch = QLatin1Char(' '); + QVERIFY(ch != 0); + QVERIFY(!(ch == 0)); + + QVERIFY(ch == 0x20); + QVERIFY(!(ch != 0x20)); + QVERIFY(0x20 == ch); + QVERIFY(!(0x20 != ch)); + } + { + const QChar ch = QLatin1Char('\0'); + QVERIFY(ch == 0); + QVERIFY(!(ch != 0)); + + QVERIFY(ch != 0x20); + QVERIFY(!(ch == 0x20)); + QVERIFY(0x20 != ch); + QVERIFY(!(0x20 == ch)); + } +} + void tst_QChar::operators_data() { QTest::addColumn("lhs");