Fix a bug in some QString comparison operators
Some comparison operators comparing to const char * where not implemented correctly. Task-number: QTBUG-34024 Change-Id: Idbdc64c8ed93e88d9f2b2f55213bc785b33cb543 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
This commit is contained in:
parent
909dbb92eb
commit
9eba69d7f9
@ -1029,13 +1029,13 @@ inline QT_ASCII_CAST_WARN bool operator==(const char *s1, const QString &s2)
|
||||
inline QT_ASCII_CAST_WARN bool operator!=(const char *s1, const QString &s2)
|
||||
{ return QString::compare_helper(s2.constData(), s2.size(), s1, -1) != 0; }
|
||||
inline QT_ASCII_CAST_WARN bool operator<(const char *s1, const QString &s2)
|
||||
{ return QString::compare_helper(s2.constData(), s2.size(), s1, -1) < 0; }
|
||||
inline QT_ASCII_CAST_WARN bool operator>(const char *s1, const QString &s2)
|
||||
{ return QString::compare_helper(s2.constData(), s2.size(), s1, -1) > 0; }
|
||||
inline QT_ASCII_CAST_WARN bool operator>(const char *s1, const QString &s2)
|
||||
{ return QString::compare_helper(s2.constData(), s2.size(), s1, -1) < 0; }
|
||||
inline QT_ASCII_CAST_WARN bool operator<=(const char *s1, const QString &s2)
|
||||
{ return QString::compare_helper(s2.constData(), s2.size(), s1, -1) <= 0; }
|
||||
inline QT_ASCII_CAST_WARN bool operator>=(const char *s1, const QString &s2)
|
||||
{ return QString::compare_helper(s2.constData(), s2.size(), s1, -1) >= 0; }
|
||||
inline QT_ASCII_CAST_WARN bool operator>=(const char *s1, const QString &s2)
|
||||
{ return QString::compare_helper(s2.constData(), s2.size(), s1, -1) <= 0; }
|
||||
|
||||
inline QT_ASCII_CAST_WARN bool operator==(const char *s1, QLatin1String s2)
|
||||
{ return QString::fromUtf8(s1) == s2; }
|
||||
|
@ -4419,6 +4419,62 @@ void tst_QString::operator_smaller()
|
||||
// operator< is not locale-aware (or shouldn't be)
|
||||
QVERIFY( foo < QString("\xc3\xa9") );
|
||||
QVERIFY( foo < "\xc3\xa9" );
|
||||
|
||||
QVERIFY(QString("a") < QString("b"));
|
||||
QVERIFY(QString("a") <= QString("b"));
|
||||
QVERIFY(QString("a") <= QString("a"));
|
||||
QVERIFY(QString("a") == QString("a"));
|
||||
QVERIFY(QString("a") >= QString("a"));
|
||||
QVERIFY(QString("b") >= QString("a"));
|
||||
QVERIFY(QString("b") > QString("a"));
|
||||
|
||||
QVERIFY("a" < QString("b"));
|
||||
QVERIFY("a" <= QString("b"));
|
||||
QVERIFY("a" <= QString("a"));
|
||||
QVERIFY("a" == QString("a"));
|
||||
QVERIFY("a" >= QString("a"));
|
||||
QVERIFY("b" >= QString("a"));
|
||||
QVERIFY("b" > QString("a"));
|
||||
|
||||
QVERIFY(QString("a") < "b");
|
||||
QVERIFY(QString("a") <= "b");
|
||||
QVERIFY(QString("a") <= "a");
|
||||
QVERIFY(QString("a") == "a");
|
||||
QVERIFY(QString("a") >= "a");
|
||||
QVERIFY(QString("b") >= "a");
|
||||
QVERIFY(QString("b") > "a");
|
||||
|
||||
QVERIFY(QLatin1String("a") < QString("b"));
|
||||
QVERIFY(QLatin1String("a") <= QString("b"));
|
||||
QVERIFY(QLatin1String("a") <= QString("a"));
|
||||
QVERIFY(QLatin1String("a") == QString("a"));
|
||||
QVERIFY(QLatin1String("a") >= QString("a"));
|
||||
QVERIFY(QLatin1String("b") >= QString("a"));
|
||||
QVERIFY(QLatin1String("b") > QString("a"));
|
||||
|
||||
QVERIFY(QString("a") < QLatin1String("b"));
|
||||
QVERIFY(QString("a") <= QLatin1String("b"));
|
||||
QVERIFY(QString("a") <= QLatin1String("a"));
|
||||
QVERIFY(QString("a") == QLatin1String("a"));
|
||||
QVERIFY(QString("a") >= QLatin1String("a"));
|
||||
QVERIFY(QString("b") >= QLatin1String("a"));
|
||||
QVERIFY(QString("b") > QLatin1String("a"));
|
||||
|
||||
QVERIFY("a" < QLatin1String("b"));
|
||||
QVERIFY("a" <= QLatin1String("b"));
|
||||
QVERIFY("a" <= QLatin1String("a"));
|
||||
QVERIFY("a" == QLatin1String("a"));
|
||||
QVERIFY("a" >= QLatin1String("a"));
|
||||
QVERIFY("b" >= QLatin1String("a"));
|
||||
QVERIFY("b" > QLatin1String("a"));
|
||||
|
||||
QVERIFY(QLatin1String("a") < "b");
|
||||
QVERIFY(QLatin1String("a") <= "b");
|
||||
QVERIFY(QLatin1String("a") <= "a");
|
||||
QVERIFY(QLatin1String("a") == "a");
|
||||
QVERIFY(QLatin1String("a") >= "a");
|
||||
QVERIFY(QLatin1String("b") >= "a");
|
||||
QVERIFY(QLatin1String("b") > "a");
|
||||
}
|
||||
|
||||
void tst_QString::integer_conversion_data()
|
||||
|
Loading…
Reference in New Issue
Block a user