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) <ogoffart@woboq.com>
This commit is contained in:
Marc Mutz 2015-12-13 02:41:55 +01:00
parent e5a20cb864
commit a8ff0bc887

View File

@ -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<QChar>("lhs");