summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2020-01-31 12:11:54 +0100
committerLars Knoll <lars.knoll@qt.io>2020-04-09 20:03:25 +0200
commitc6cdf38e752c22babdbe645366bdfb7ce51d01ff (patch)
tree450b02523cb5a16791674ad1d06fb68c72eac971 /tests/auto
parent775945137b6ef62de9a7d416b1fe59d79006ba82 (diff)
Change qHash() to work with size_t instead of uint
This is required, so that QHash and QSet can hold more than 2^32 items on 64 bit platforms. The actual hashing functions for strings are still 32bit, this will be changed in a follow-up commit. Change-Id: I4372125252486075ff3a0b45ecfa818359fe103b Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/corelib/plugin/quuid/tst_quuid.cpp2
-rw-r--r--tests/auto/corelib/tools/collections/tst_collections.cpp6
-rw-r--r--tests/auto/corelib/tools/containerapisymmetry/tst_containerapisymmetry.cpp6
-rw-r--r--tests/auto/corelib/tools/qcache/tst_qcache.cpp2
-rw-r--r--tests/auto/corelib/tools/qhash/tst_qhash.cpp34
-rw-r--r--tests/auto/corelib/tools/qhashfunctions/tst_qhashfunctions.cpp10
-rw-r--r--tests/auto/corelib/tools/qset/tst_qset.cpp2
-rw-r--r--tests/auto/corelib/tools/qvector/tst_qvector.cpp4
-rw-r--r--tests/auto/gui/painting/qpainter/tst_qpainter.cpp2
9 files changed, 34 insertions, 34 deletions
diff --git a/tests/auto/corelib/plugin/quuid/tst_quuid.cpp b/tests/auto/corelib/plugin/quuid/tst_quuid.cpp
index 16552059dd..7abe7ebdc6 100644
--- a/tests/auto/corelib/plugin/quuid/tst_quuid.cpp
+++ b/tests/auto/corelib/plugin/quuid/tst_quuid.cpp
@@ -441,7 +441,7 @@ void tst_QUuid::processUniqueness()
void tst_QUuid::hash()
{
- uint h = qHash(uuidA);
+ size_t h = qHash(uuidA);
QCOMPARE(qHash(uuidA), h);
QCOMPARE(qHash(QUuid(uuidA.toString())), h);
}
diff --git a/tests/auto/corelib/tools/collections/tst_collections.cpp b/tests/auto/corelib/tools/collections/tst_collections.cpp
index 456c3e6cf9..2059cf74cf 100644
--- a/tests/auto/corelib/tools/collections/tst_collections.cpp
+++ b/tests/auto/corelib/tools/collections/tst_collections.cpp
@@ -2604,7 +2604,7 @@ public:
bool operator==(const EqualsComparable &) const { return true; }
};
-uint qHash(const EqualsComparable &)
+size_t qHash(const EqualsComparable &)
{
return 0;
}
@@ -2917,7 +2917,7 @@ public:
inline bool operator==(const Aligned4 &other) const { return i == other.i; }
inline bool operator<(const Aligned4 &other) const { return i < other.i; }
- friend inline int qHash(const Aligned4 &a) { return qHash(a.i); }
+ friend inline size_t qHash(const Aligned4 &a) { return qHash(a.i); }
};
Q_STATIC_ASSERT(alignof(Aligned4) % 4 == 0);
@@ -3069,7 +3069,7 @@ template<template<class, class> class C> void QTBUG13079_collectionInsideCollect
}
-quint32 qHash(const QTBUG13079_Node<QSet> &)
+size_t qHash(const QTBUG13079_Node<QSet> &)
{
return 0;
}
diff --git a/tests/auto/corelib/tools/containerapisymmetry/tst_containerapisymmetry.cpp b/tests/auto/corelib/tools/containerapisymmetry/tst_containerapisymmetry.cpp
index fe6e82e19c..8c90822ec8 100644
--- a/tests/auto/corelib/tools/containerapisymmetry/tst_containerapisymmetry.cpp
+++ b/tests/auto/corelib/tools/containerapisymmetry/tst_containerapisymmetry.cpp
@@ -91,7 +91,7 @@ bool operator==(Movable lhs, Movable rhs) Q_DECL_NOTHROW { return lhs.i == rhs.i
bool operator!=(Movable lhs, Movable rhs) Q_DECL_NOTHROW { return lhs.i != rhs.i; }
bool operator<(Movable lhs, Movable rhs) Q_DECL_NOTHROW { return lhs.i < rhs.i; }
-uint qHash(Movable m, uint seed = 0) Q_DECL_NOTHROW { return qHash(m.i, seed); }
+size_t qHash(Movable m, size_t seed = 0) Q_DECL_NOTHROW { return qHash(m.i, seed); }
QDebug &operator<<(QDebug &d, Movable m)
{
const QDebugStateSaver saver(d);
@@ -130,7 +130,7 @@ bool operator==(Complex lhs, Complex rhs) Q_DECL_NOTHROW { return lhs.i == rhs.i
bool operator!=(Complex lhs, Complex rhs) Q_DECL_NOTHROW { return lhs.i != rhs.i; }
bool operator<(Complex lhs, Complex rhs) Q_DECL_NOTHROW { return lhs.i < rhs.i; }
-uint qHash(Complex c, uint seed = 0) Q_DECL_NOTHROW { return qHash(c.i, seed); }
+size_t qHash(Complex c, size_t seed = 0) Q_DECL_NOTHROW { return qHash(c.i, seed); }
QDebug &operator<<(QDebug &d, Complex c)
{
const QDebugStateSaver saver(d);
@@ -171,7 +171,7 @@ bool operator<(DuplicateStrategyTestType lhs, DuplicateStrategyTestType rhs) Q_D
return lhs.i < rhs.i;
}
-uint qHash(DuplicateStrategyTestType c, uint seed = 0) Q_DECL_NOTHROW
+size_t qHash(DuplicateStrategyTestType c, size_t seed = 0) Q_DECL_NOTHROW
{
return qHash(c.i, seed);
}
diff --git a/tests/auto/corelib/tools/qcache/tst_qcache.cpp b/tests/auto/corelib/tools/qcache/tst_qcache.cpp
index af74553ab4..f122e45e87 100644
--- a/tests/auto/corelib/tools/qcache/tst_qcache.cpp
+++ b/tests/auto/corelib/tools/qcache/tst_qcache.cpp
@@ -378,7 +378,7 @@ bool operator==(const KeyType &key1, const KeyType &key2)
return key1.foo == key2.foo;
}
-uint qHash(const KeyType &key)
+size_t qHash(const KeyType &key)
{
return qHash(key.foo);
}
diff --git a/tests/auto/corelib/tools/qhash/tst_qhash.cpp b/tests/auto/corelib/tools/qhash/tst_qhash.cpp
index b987adaa3f..da1cb15cd8 100644
--- a/tests/auto/corelib/tools/qhash/tst_qhash.cpp
+++ b/tests/auto/corelib/tools/qhash/tst_qhash.cpp
@@ -77,7 +77,7 @@ struct IdentityTracker {
int value, id;
};
-inline uint qHash(IdentityTracker key) { return qHash(key.value); }
+inline size_t qHash(IdentityTracker key) { return qHash(key.value); }
inline bool operator==(IdentityTracker lhs, IdentityTracker rhs) { return lhs.value == rhs.value; }
@@ -1337,52 +1337,52 @@ static int wrongqHashOverload = 0;
struct OneArgumentQHashStruct1 {};
bool operator==(const OneArgumentQHashStruct1 &, const OneArgumentQHashStruct1 &) { return false; }
-uint qHash(OneArgumentQHashStruct1) { return 0; }
+size_t qHash(OneArgumentQHashStruct1) { return 0; }
struct OneArgumentQHashStruct2 {};
bool operator==(const OneArgumentQHashStruct2 &, const OneArgumentQHashStruct2 &) { return false; }
-uint qHash(const OneArgumentQHashStruct2 &) { return 0; }
+size_t qHash(const OneArgumentQHashStruct2 &) { return 0; }
struct OneArgumentQHashStruct3 {};
bool operator==(const OneArgumentQHashStruct3 &, const OneArgumentQHashStruct3 &) { return false; }
-uint qHash(OneArgumentQHashStruct3) { return 0; }
-uint qHash(OneArgumentQHashStruct3 &, uint) { wrongqHashOverload = 1; return 0; }
+size_t qHash(OneArgumentQHashStruct3) { return 0; }
+size_t qHash(OneArgumentQHashStruct3 &, size_t) { wrongqHashOverload = 1; return 0; }
struct OneArgumentQHashStruct4 {};
bool operator==(const OneArgumentQHashStruct4 &, const OneArgumentQHashStruct4 &) { return false; }
-uint qHash(const OneArgumentQHashStruct4 &) { return 0; }
-uint qHash(OneArgumentQHashStruct4 &, uint) { wrongqHashOverload = 1; return 0; }
+size_t qHash(const OneArgumentQHashStruct4 &) { return 0; }
+size_t qHash(OneArgumentQHashStruct4 &, size_t) { wrongqHashOverload = 1; return 0; }
struct TwoArgumentsQHashStruct1 {};
bool operator==(const TwoArgumentsQHashStruct1 &, const TwoArgumentsQHashStruct1 &) { return false; }
-uint qHash(const TwoArgumentsQHashStruct1 &) { wrongqHashOverload = 1; return 0; }
-uint qHash(const TwoArgumentsQHashStruct1 &, uint) { return 0; }
+size_t qHash(const TwoArgumentsQHashStruct1 &) { wrongqHashOverload = 1; return 0; }
+size_t qHash(const TwoArgumentsQHashStruct1 &, size_t) { return 0; }
struct TwoArgumentsQHashStruct2 {};
bool operator==(const TwoArgumentsQHashStruct2 &, const TwoArgumentsQHashStruct2 &) { return false; }
-uint qHash(TwoArgumentsQHashStruct2) { wrongqHashOverload = 1; return 0; }
-uint qHash(const TwoArgumentsQHashStruct2 &, uint) { return 0; }
+size_t qHash(TwoArgumentsQHashStruct2) { wrongqHashOverload = 1; return 0; }
+size_t qHash(const TwoArgumentsQHashStruct2 &, size_t) { return 0; }
struct TwoArgumentsQHashStruct3 {};
bool operator==(const TwoArgumentsQHashStruct3 &, const TwoArgumentsQHashStruct3 &) { return false; }
-uint qHash(const TwoArgumentsQHashStruct3 &) { wrongqHashOverload = 1; return 0; }
-uint qHash(TwoArgumentsQHashStruct3, uint) { return 0; }
+size_t qHash(const TwoArgumentsQHashStruct3 &) { wrongqHashOverload = 1; return 0; }
+size_t qHash(TwoArgumentsQHashStruct3, size_t) { return 0; }
struct TwoArgumentsQHashStruct4 {};
bool operator==(const TwoArgumentsQHashStruct4 &, const TwoArgumentsQHashStruct4 &) { return false; }
-uint qHash(TwoArgumentsQHashStruct4) { wrongqHashOverload = 1; return 0; }
-uint qHash(TwoArgumentsQHashStruct4, uint) { return 0; }
+size_t qHash(TwoArgumentsQHashStruct4) { wrongqHashOverload = 1; return 0; }
+size_t qHash(TwoArgumentsQHashStruct4, size_t) { return 0; }
/*!
\internal
Check that QHash picks up the right overload.
The best one, for a type T, is the two-args version of qHash:
- either uint qHash(T, uint) or uint qHash(const T &, uint).
+ either size_t qHash(T, size_t) or size_t qHash(const T &, size_t).
If neither of these exists, then one between
- uint qHash(T) or uint qHash(const T &) must exist
+ size_t qHash(T) or size_t qHash(const T &) must exist
(and it gets selected instead).
*/
void tst_QHash::twoArguments_qHash()
diff --git a/tests/auto/corelib/tools/qhashfunctions/tst_qhashfunctions.cpp b/tests/auto/corelib/tools/qhashfunctions/tst_qhashfunctions.cpp
index f76f3aa0c6..c23c08bd7c 100644
--- a/tests/auto/corelib/tools/qhashfunctions/tst_qhashfunctions.cpp
+++ b/tests/auto/corelib/tools/qhashfunctions/tst_qhashfunctions.cpp
@@ -105,8 +105,8 @@ void tst_QHashFunctions::qhash()
a2.resize(1);
a2.setBit(0, false);
- uint h1 = qHash(a1, seed);
- uint h2 = qHash(a2, seed);
+ size_t h1 = qHash(a1, seed);
+ size_t h2 = qHash(a2, seed);
QVERIFY(h1 != h2); // not guaranteed
@@ -124,14 +124,14 @@ void tst_QHashFunctions::qhash()
QVERIFY(h1 == h2);
a2.setBit(0, false);
- uint h3 = qHash(a2, seed);
+ size_t h3 = qHash(a2, seed);
QVERIFY(h2 != h3); // not guaranteed
a2.setBit(0, true);
QVERIFY(h2 == qHash(a2, seed));
a2.setBit(6, false);
- uint h4 = qHash(a2, seed);
+ size_t h4 = qHash(a2, seed);
QVERIFY(h2 != h4); // not guaranteed
a2.setBit(6, true);
@@ -228,7 +228,7 @@ void tst_QHashFunctions::qthash()
namespace SomeNamespace {
struct Hashable { int i; };
- inline uint qHash(Hashable h, uint seed = 0)
+ inline size_t qHash(Hashable h, size_t seed = 0)
{ return QT_PREPEND_NAMESPACE(qHash)(h.i, seed); }
}
diff --git a/tests/auto/corelib/tools/qset/tst_qset.cpp b/tests/auto/corelib/tools/qset/tst_qset.cpp
index 21ceee87c0..ee6cf7f533 100644
--- a/tests/auto/corelib/tools/qset/tst_qset.cpp
+++ b/tests/auto/corelib/tools/qset/tst_qset.cpp
@@ -74,7 +74,7 @@ struct IdentityTracker {
int value, id;
};
-inline uint qHash(IdentityTracker key) { return qHash(key.value); }
+inline size_t qHash(IdentityTracker key) { return qHash(key.value); }
inline bool operator==(IdentityTracker lhs, IdentityTracker rhs) { return lhs.value == rhs.value; }
void tst_QSet::operator_eq()
diff --git a/tests/auto/corelib/tools/qvector/tst_qvector.cpp b/tests/auto/corelib/tools/qvector/tst_qvector.cpp
index 6ae312fb8d..739c841ae1 100644
--- a/tests/auto/corelib/tools/qvector/tst_qvector.cpp
+++ b/tests/auto/corelib/tools/qvector/tst_qvector.cpp
@@ -108,7 +108,7 @@ private:
}
};
-inline uint qHash(const Movable &key, uint seed = 0) { return qHash(key.i, seed); }
+inline size_t qHash(const Movable &key, size_t seed = 0) { return qHash(key.i, seed); }
QAtomicInt Movable::counter = 0;
QT_BEGIN_NAMESPACE
@@ -179,7 +179,7 @@ private:
};
QAtomicInt Custom::counter = 0;
-inline uint qHash(const Custom &key, uint seed = 0) { return qHash(key.i, seed); }
+inline size_t qHash(const Custom &key, size_t seed = 0) { return qHash(key.i, seed); }
Q_DECLARE_METATYPE(Custom);
diff --git a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
index ce88c6a7a4..75ab0810ca 100644
--- a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
+++ b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
@@ -3289,7 +3289,7 @@ void tst_QPainter::imageScaling_task206785()
#define FOR_EACH_NEIGHBOR_8 for (int dx = -1; dx <= 1; ++dx) for (int dy = -1; dy <= 1; ++dy) if (dx != 0 || dy != 0)
#define FOR_EACH_NEIGHBOR_4 for (int dx = -1; dx <= 1; ++dx) for (int dy = -1; dy <= 1; ++dy) if ((dx == 0) != (dy == 0))
-uint qHash(const QPoint &point)
+size_t qHash(const QPoint &point)
{
return qHash(qMakePair(point.x(), point.y()));
}