QHashFunctions: test for hash equality of null and empty string types
In Qt, null QStrings compare equal to empty ones, so add an explicit check that the corresponding hash values are identical, too. Ditto for QByteArray. Change-Id: I190fc95a765305928d9b6b0e4955433865b6b247 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
7c279d779b
commit
6a7bae9a26
@ -45,6 +45,8 @@ class tst_QHashFunctions : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void qhash();
|
void qhash();
|
||||||
|
void qhash_of_empty_and_null_qstring();
|
||||||
|
void qhash_of_empty_and_null_qbytearray();
|
||||||
void fp_qhash_of_zero_is_zero();
|
void fp_qhash_of_zero_is_zero();
|
||||||
void qthash_data();
|
void qthash_data();
|
||||||
void qthash();
|
void qthash();
|
||||||
@ -117,6 +119,20 @@ void tst_QHashFunctions::qhash()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tst_QHashFunctions::qhash_of_empty_and_null_qstring()
|
||||||
|
{
|
||||||
|
QString null, empty("");
|
||||||
|
QCOMPARE(null, empty);
|
||||||
|
QCOMPARE(qHash(null), qHash(empty));
|
||||||
|
}
|
||||||
|
|
||||||
|
void tst_QHashFunctions::qhash_of_empty_and_null_qbytearray()
|
||||||
|
{
|
||||||
|
QByteArray null, empty("");
|
||||||
|
QCOMPARE(null, empty);
|
||||||
|
QCOMPARE(qHash(null), qHash(empty));
|
||||||
|
}
|
||||||
|
|
||||||
void tst_QHashFunctions::fp_qhash_of_zero_is_zero()
|
void tst_QHashFunctions::fp_qhash_of_zero_is_zero()
|
||||||
{
|
{
|
||||||
QCOMPARE(qHash(-0.0f), 0U);
|
QCOMPARE(qHash(-0.0f), 0U);
|
||||||
|
Loading…
Reference in New Issue
Block a user