From f98a20a6904cca16595f04c59d6729fd41cb4886 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 17 Jan 2020 09:22:21 +0100 Subject: Prepare for separating QHash and QMultiHash Prepare the test cases so that QHash and QMultiHash are used as if they were fully independent classes. Change-Id: Iaf5d65c8f6321ec2edaef490e657b144619655a0 Reviewed-by: Simon Hausmann --- tests/auto/corelib/tools/qhash/tst_qhash.cpp | 221 ++++++++++----------------- 1 file changed, 79 insertions(+), 142 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/tools/qhash/tst_qhash.cpp b/tests/auto/corelib/tools/qhash/tst_qhash.cpp index 91cd3eb0bd..5dc1800569 100644 --- a/tests/auto/corelib/tools/qhash/tst_qhash.cpp +++ b/tests/auto/corelib/tools/qhash/tst_qhash.cpp @@ -451,20 +451,6 @@ void tst_QHash::insert1() QCOMPARE(hash.find(searchKey).value(), id01.id); // last-inserted value QCOMPARE(hash.find(searchKey).key().id, id00.id); // but first-inserted key } - { - QMultiHash hash; - QCOMPARE(hash.size(), 0); - const int dummy = -1; - IdentityTracker id00 = {0, 0}, id01 = {0, 1}, searchKey = {0, dummy}; - QCOMPARE(hash.insert(id00, id00.id).key().id, id00.id); - QCOMPARE(hash.size(), 1); - QCOMPARE(hash.insert(id01, id01.id).key().id, id01.id); - QCOMPARE(hash.size(), 2); - QMultiHash::const_iterator pos = hash.constFind(searchKey); - QCOMPARE(pos.value(), pos.key().id); // key fits to value it was inserted with - ++pos; - QCOMPARE(pos.value(), pos.key().id); // key fits to value it was inserted with - } } void tst_QHash::erase() @@ -491,13 +477,15 @@ void tst_QHash::erase() ++n; } QVERIFY(n == 3); - QHash h2; - h2.insertMulti(20, 41); - h2.insertMulti(20, 42); + + QMultiHash h2; + h2.insert(20, 41); + h2.insert(20, 42); QVERIFY(h2.size() == 2); - it1 = h2.erase(h2.begin()); - it1 = h2.erase(h2.begin()); - QVERIFY(it1 == h2.end()); + auto bit = h2.begin(); + auto mit = h2.erase(bit); + mit = h2.erase(h2.begin()); + QVERIFY(mit == h2.end()); } void tst_QHash::key() @@ -631,14 +619,15 @@ void tst_QHash::find() QCOMPARE(map1.find(1).value(), QLatin1String("Mayer")); QCOMPARE(map1.find(2).value(), QLatin1String("Hej")); - for(i = 3; i < 10; ++i) { + QMultiHash multiMap(map1); + for (i = 3; i < 10; ++i) { compareString = testString.arg(i); - map1.insertMulti(4, compareString); + multiMap.insert(4, compareString); } - QHash::const_iterator it=map1.constFind(4); + auto it = multiMap.constFind(4); - for(i = 9; i > 2 && it != map1.constEnd() && it.key() == 4; --i) { + for (i = 9; i > 2 && it != multiMap.constEnd() && it.key() == 4; --i) { compareString = testString.arg(i); QVERIFY(it.value() == compareString); ++it; @@ -664,14 +653,15 @@ void tst_QHash::constFind() QCOMPARE(map1.constFind(1).value(), QLatin1String("Mayer")); QCOMPARE(map1.constFind(2).value(), QLatin1String("Hej")); - for(i = 3; i < 10; ++i) { + QMultiHash multiMap(map1); + for (i = 3; i < 10; ++i) { compareString = testString.arg(i); - map1.insertMulti(4, compareString); + multiMap.insert(4, compareString); } - QHash::const_iterator it=map1.constFind(4); + auto it = multiMap.constFind(4); - for(i = 9; i > 2 && it != map1.constEnd() && it.key() == 4; --i) { + for (i = 9; i > 2 && it != multiMap.constEnd() && it.key() == 4; --i) { compareString = testString.arg(i); QVERIFY(it.value() == compareString); ++it; @@ -689,9 +679,9 @@ void tst_QHash::contains() map1.insert(1, "one"); QVERIFY(map1.contains(1)); - for(i=2; i < 100; ++i) + for (i=2; i < 100; ++i) map1.insert(i, "teststring"); - for(i=99; i > 1; --i) + for (i=99; i > 1; --i) QVERIFY(map1.contains(i)); map1.remove(43); @@ -855,33 +845,33 @@ void tst_QHash::operator_eq() // regardless of insertion or iteration order { - QHash a; - QHash b; + QMultiHash a; + QMultiHash b; - a.insertMulti(0, 0); - a.insertMulti(0, 1); + a.insert(0, 0); + a.insert(0, 1); - b.insertMulti(0, 1); - b.insertMulti(0, 0); + b.insert(0, 1); + b.insert(0, 0); QVERIFY(a == b); QVERIFY(!(a != b)); } { - QHash a; - QHash b; + QMultiHash a; + QMultiHash b; enum { Count = 100 }; for (int key = 0; key < Count; ++key) { for (int value = 0; value < Count; ++value) - a.insertMulti(key, value); + a.insert(key, value); } for (int key = Count - 1; key >= 0; --key) { for (int value = 0; value < Count; ++value) - b.insertMulti(key, value); + b.insert(key, value); } QVERIFY(a == b); @@ -889,8 +879,8 @@ void tst_QHash::operator_eq() } { - QHash a; - QHash b; + QMultiHash a; + QMultiHash b; enum { Count = 100, @@ -900,7 +890,7 @@ void tst_QHash::operator_eq() for (int key = 0; key < Count; ++key) { for (int value = 0; value < Count; ++value) - a.insertMulti(key, value); + a.insert(key, value); } // Generates two permutations of [0, Count) for the keys and values, @@ -909,7 +899,7 @@ void tst_QHash::operator_eq() for (int k = 0; k < Count; ++k) { const int key = (k * KeyStep) % Count; for (int v = 0; v < Count; ++v) - b.insertMulti(key, (v * ValueStep) % Count); + b.insert(key, (v * ValueStep) % Count); } QVERIFY(a == b); @@ -923,10 +913,10 @@ void tst_QHash::compare() QString testString = "Teststring %1"; int i; - for(i = 0; i < 1000; ++i) + for (i = 0; i < 1000; ++i) hash1.insert(i,testString.arg(i)); - for(--i; i >= 0; --i) + for (--i; i >= 0; --i) hash2.insert(i,testString.arg(i)); hash1.squeeze(); @@ -947,39 +937,39 @@ void tst_QHash::compare() void tst_QHash::compare2() { - QHash a; - QHash b; + QMultiHash a; + QMultiHash b; - a.insertMulti(17, 1); - a.insertMulti(17 * 2, 1); - b.insertMulti(17 * 2, 1); - b.insertMulti(17, 1); + a.insert(17, 1); + a.insert(17 * 2, 1); + b.insert(17 * 2, 1); + b.insert(17, 1); QVERIFY(a == b); QVERIFY(b == a); - a.insertMulti(17, 2); - a.insertMulti(17 * 2, 3); - b.insertMulti(17 * 2, 3); - b.insertMulti(17, 2); + a.insert(17, 2); + a.insert(17 * 2, 3); + b.insert(17 * 2, 3); + b.insert(17, 2); QVERIFY(a == b); QVERIFY(b == a); - a.insertMulti(17, 4); - a.insertMulti(17 * 2, 5); - b.insertMulti(17 * 2, 4); - b.insertMulti(17, 5); + a.insert(17, 4); + a.insert(17 * 2, 5); + b.insert(17 * 2, 4); + b.insert(17, 5); QVERIFY(!(a == b)); QVERIFY(!(b == a)); a.clear(); b.clear(); - a.insertMulti(1, 1); - a.insertMulti(1, 2); - a.insertMulti(1, 3); - b.insertMulti(1, 1); - b.insertMulti(1, 2); - b.insertMulti(1, 3); - b.insertMulti(1, 4); + a.insert(1, 1); + a.insert(1, 2); + a.insert(1, 3); + b.insert(1, 1); + b.insert(1, 2); + b.insert(1, 3); + b.insert(1, 4); QVERIFY(!(a == b)); QVERIFY(!(b == a)); } @@ -993,7 +983,7 @@ void tst_QHash::iterators() QString testString1; int i; - for(i = 1; i < 100; ++i) + for (i = 1; i < 100; ++i) hash.insert(i, testString.arg(i)); //to get some chaos in the hash @@ -1010,18 +1000,13 @@ void tst_QHash::iterators() QVERIFY(stlIt.value() == testMap.value(1)); - stlIt+=5; + for (int i = 0; i < 5; ++i) + ++stlIt; QVERIFY(stlIt.value() == testMap.value(6)); stlIt++; QVERIFY(stlIt.value() == testMap.value(7)); - stlIt-=3; - QVERIFY(stlIt.value() == testMap.value(4)); - - stlIt--; - QVERIFY(stlIt.value() == testMap.value(3)); - testMap.clear(); //STL-Style const-iterators @@ -1035,18 +1020,13 @@ void tst_QHash::iterators() QVERIFY(cstlIt.value() == testMap.value(1)); - cstlIt+=5; + for (int i = 0; i < 5; ++i) + ++cstlIt; QVERIFY(cstlIt.value() == testMap.value(6)); cstlIt++; QVERIFY(cstlIt.value() == testMap.value(7)); - cstlIt-=3; - QVERIFY(cstlIt.value() == testMap.value(4)); - - cstlIt--; - QVERIFY(cstlIt.value() == testMap.value(3)); - testMap.clear(); //Java-Style iterators @@ -1068,14 +1048,7 @@ void tst_QHash::iterators() QVERIFY(javaIt.value() == testMap.value(i)); } - ++i; - while(javaIt.hasPrevious()) { - --i; - javaIt.previous(); - QVERIFY(javaIt.value() == testMap.value(i)); - } - - //peekNext() peekPrevious() + //peekNext() javaIt.toFront(); javaIt.next(); while(javaIt.hasNext()) { @@ -1083,14 +1056,6 @@ void tst_QHash::iterators() testString1 = javaIt.peekNext().value(); javaIt.next(); QVERIFY(javaIt.value() == testString1); - QCOMPARE(javaIt.peekPrevious().value(), testString1); - } - while(javaIt.hasPrevious()) { - testString = javaIt.value(); - testString1 = javaIt.peekPrevious().value(); - javaIt.previous(); - QVERIFY(javaIt.value() == testString1); - QCOMPARE(javaIt.peekNext().value(), testString1); } } @@ -1115,9 +1080,7 @@ void tst_QHash::keyIterator() QVERIFY(key_it != hash.keyEnd()); QCOMPARE(*key_it, it.key()); QCOMPARE(*(key_it++), (it++).key()); - QCOMPARE(*(key_it--), (it--).key()); QCOMPARE(*(++key_it), (++it).key()); - QCOMPARE(*(--key_it), (--it).key()); QCOMPARE(std::count(hash.keyBegin(), hash.keyEnd(), 99), 1); @@ -1164,17 +1127,6 @@ void tst_QHash::keyValueIterator() ++key_value_it; QCOMPARE(*key_value_it, entry_type(it.key(), it.value())); - --it; - --key_value_it; - QCOMPARE(*key_value_it, entry_type(it.key(), it.value())); - - ++it; - ++key_value_it; - QCOMPARE(*key_value_it, entry_type(it.key(), it.value())); - - --it; - --key_value_it; - QCOMPARE(*key_value_it, entry_type(it.key(), it.value())); key = 99; value = 99 * 100; QCOMPARE(std::count(hash.constKeyValueBegin(), hash.constKeyValueEnd(), entry_type(key, value)), 1); @@ -1184,9 +1136,9 @@ void tst_QHash::rehash_isnt_quadratic() { // this test should be incredibly slow if rehash() is quadratic for (int j = 0; j < 5; ++j) { - QHash testHash; + QMultiHash testHash; for (int i = 0; i < 500000; ++i) - testHash.insertMulti(1, 1); + testHash.insert(1, 1); } } @@ -1330,27 +1282,27 @@ QList sorted(const QList &list) void tst_QHash::keys_values_uniqueKeys() { - QHash hash; + QMultiHash hash; QVERIFY(hash.uniqueKeys().isEmpty()); QVERIFY(hash.keys().isEmpty()); QVERIFY(hash.values().isEmpty()); - hash.insertMulti("alpha", 1); + hash.insert("alpha", 1); QVERIFY(sorted(hash.keys()) == (QList() << "alpha")); QVERIFY(hash.keys() == hash.uniqueKeys()); QVERIFY(hash.values() == (QList() << 1)); - hash.insertMulti("beta", -2); + hash.insert("beta", -2); QVERIFY(sorted(hash.keys()) == (QList() << "alpha" << "beta")); QVERIFY(hash.keys() == hash.uniqueKeys()); QVERIFY(sorted(hash.values()) == sorted(QList() << 1 << -2)); - hash.insertMulti("alpha", 2); + hash.insert("alpha", 2); QVERIFY(sorted(hash.uniqueKeys()) == (QList() << "alpha" << "beta")); QVERIFY(sorted(hash.keys()) == (QList() << "alpha" << "alpha" << "beta")); QVERIFY(sorted(hash.values()) == sorted(QList() << 2 << 1 << -2)); - hash.insertMulti("beta", 4); + hash.insert("beta", 4); QVERIFY(sorted(hash.uniqueKeys()) == (QList() << "alpha" << "beta")); QVERIFY(sorted(hash.keys()) == (QList() << "alpha" << "alpha" << "beta" << "beta")); QVERIFY(sorted(hash.values()) == sorted(QList() << 2 << 1 << 4 << -2)); @@ -1504,14 +1456,14 @@ void tst_QHash::initializerList() void tst_QHash::eraseValidIteratorOnSharedHash() { - QHash a, b; + QMultiHash a, b; a.insert(10, 10); - a.insertMulti(10, 25); - a.insertMulti(10, 30); + a.insert(10, 25); + a.insert(10, 30); a.insert(20, 20); a.insert(40, 40); - QHash::iterator i = a.begin(); + auto i = a.begin(); while (i.value() != 25) ++i; @@ -1533,7 +1485,7 @@ void tst_QHash::eraseValidIteratorOnSharedHash() void tst_QHash::equal_range() { - QHash hash; + QMultiHash hash; auto result = hash.equal_range(0); QCOMPARE(result.first, hash.end()); @@ -1546,7 +1498,7 @@ void tst_QHash::equal_range() QCOMPARE(result.first, hash.find(1)); QVERIFY(std::distance(result.first, result.second) == 1); - QHash h1; + QMultiHash h1; { auto p = h1.equal_range(0); QVERIFY(p.first == p.second); @@ -1597,7 +1549,7 @@ void tst_QHash::equal_range() QVERIFY(p2.first == m1.begin() || p2.second == m1.end()); } - const QHash ch1 = h1; + const QMultiHash ch1 = h1; { auto p1 = ch1.equal_range(9); QVERIFY(p1.first == p1.second); @@ -1623,10 +1575,10 @@ void tst_QHash::equal_range() QVERIFY(p2.first == cm1.cbegin() || p2.second == cm1.cend()); } - QHash h2; + QMultiHash h2; for (int i = 0; i < 8; ++i) for (int j = 0; j < 8; ++j) - h2.insertMulti(i, i*j); + h2.insert(i, i*j); for (int i = 0; i < 8; ++i) { auto pair = h2.equal_range(i); @@ -1692,21 +1644,6 @@ void tst_QHash::insert_hash() QCOMPARE(hash[2], 5); QCOMPARE(hash[7], 55); } - { - // This will use a QMultiHash and then insert that into QHash, - // the ordering is undefined so we won't test that but make - // sure this isn't adding multiple entries with the same key - // to the QHash. - QHash hash; - QMultiHash hash2; - hash2.insert(0, 5); - hash2.insert(0, 6); - hash2.insert(0, 7); - - hash.insert(hash2); - - QCOMPARE(hash.count(), 1); - } } QTEST_APPLESS_MAIN(tst_QHash) -- cgit v1.2.3 From 866174307af1d6e1344578ccd09089a0e4c285a7 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 17 Jan 2020 15:56:12 +0100 Subject: Some fixes to collection autotest Split QHash and QMultiHash, and get rid of some compiler warnings. Change-Id: I48991f097f408ad5c1aa349443e26ab816e0b736 Reviewed-by: Simon Hausmann --- .../corelib/tools/collections/tst_collections.cpp | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/tools/collections/tst_collections.cpp b/tests/auto/corelib/tools/collections/tst_collections.cpp index 023b22b4ba..7da49e0917 100644 --- a/tests/auto/corelib/tools/collections/tst_collections.cpp +++ b/tests/auto/corelib/tools/collections/tst_collections.cpp @@ -1551,12 +1551,12 @@ void tst_Collections::hash() } { - QHash hash1, hash2; - hash1.insertMulti(1, "Alpha"); - hash1.insertMulti(1, "Gamma"); - hash2.insertMulti(1, "Beta"); - hash2.insertMulti(1, "Gamma"); - hash2.insertMulti(1, "Gamma"); + QMultiHash hash1, hash2; + hash1.insert(1, "Alpha"); + hash1.insert(1, "Gamma"); + hash2.insert(1, "Beta"); + hash2.insert(1, "Gamma"); + hash2.insert(1, "Gamma"); hash1.unite(hash2); QCOMPARE(hash1.size(), 5); @@ -1986,15 +1986,6 @@ void tst_Collections::qstring() QVERIFY(null.isNull()); QVERIFY(!nonNull.isNull()); -#if QT_DEPRECATED_SINCE(5, 9) - QVERIFY(null == QString::null); - QVERIFY(QString::null == null); - QVERIFY(nonNull != QString::null); - QVERIFY(QString::null != nonNull); - QVERIFY(null == nonNull); - QVERIFY(QString::null == QString::null); -#endif - QString fill = "123"; fill.fill('a'); QCOMPARE(fill, QLatin1String("aaa")); -- cgit v1.2.3 From e41d243789560278b2ced383730df7e1a20e6fc7 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 20 Jan 2020 15:36:48 +0100 Subject: Adjust autotest to coming QHash changes QHash and QMultiHash are separate classes in the future, and the iterator is not random access. Change-Id: I7e1a4162ca964001c8da81a2fd7c41ccae27bdb3 Reviewed-by: Simon Hausmann --- .../corelib/tools/collections/tst_collections.cpp | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/tools/collections/tst_collections.cpp b/tests/auto/corelib/tools/collections/tst_collections.cpp index 7da49e0917..f319244bd3 100644 --- a/tests/auto/corelib/tools/collections/tst_collections.cpp +++ b/tests/auto/corelib/tools/collections/tst_collections.cpp @@ -2701,8 +2701,10 @@ void testMapLikeStlIterators() QString t; fake.insert(k, t); - typename Container::iterator i1 = fake.begin(), i2 = i1 + 1; - typename Container::const_iterator c1 = i1, c2 = c1 + 1; + typename Container::iterator i1 = fake.begin(), i2 = i1; + ++i2; + typename Container::const_iterator c1 = i1, c2 = c1; + ++c2; QVERIFY(i1 == i1); QVERIFY(i1 == c1); @@ -2712,8 +2714,6 @@ void testMapLikeStlIterators() QVERIFY(i2 == c2); QVERIFY(c2 == i2); QVERIFY(c2 == c2); - QVERIFY(1 + i1 == i1 + 1); - QVERIFY(1 + c1 == c1 + 1); QVERIFY(i1 != i2); QVERIFY(i1 != c2); @@ -2924,10 +2924,6 @@ void instantiateMutableIterationContainer() it = container.begin(); it = container.end(); Q_UNUSED(it) - - // QSet lacks count(T). - const ValueType value = ValueType(); - container.count(value); } template @@ -2935,10 +2931,9 @@ void instantiateSequence() { instantiateMutableIterationContainer(); -// QVector lacks removeAll(T) -// ValueType value = ValueType(); -// ContainerType container; -// container.removeAll(value); + ValueType value = ValueType(); + ContainerType container; + container.removeAll(value); } template @@ -3011,11 +3006,10 @@ void instantiatePairAssociative() constContainer.keys(); container.remove(key); container.take(key); - container.unite(constContainer); + container.insert(constContainer); container.value(key); container.value(key, value); container.values(); - container.values(key); container[key]; const int foo = constContainer[key]; Q_UNUSED(foo); -- cgit v1.2.3 From c0d2deac8b3b30ab163511e83a85dba4f31c22fb Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 20 Jan 2020 15:46:49 +0100 Subject: Remove deprecated functionality from QSet Remove support for reverse iteration over a QSet. Change-Id: I1e9c986a118aea4ebeb7fcdceb41e9ce6593cdb6 Reviewed-by: Simon Hausmann --- tests/auto/corelib/tools/qset/tst_qset.cpp | 147 +---------------------------- 1 file changed, 1 insertion(+), 146 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/tools/qset/tst_qset.cpp b/tests/auto/corelib/tools/qset/tst_qset.cpp index 6638ad8b60..0ca8be7fa3 100644 --- a/tests/auto/corelib/tools/qset/tst_qset.cpp +++ b/tests/auto/corelib/tools/qset/tst_qset.cpp @@ -59,7 +59,6 @@ private slots: void begin(); void end(); void insert(); - void reverseIterators(); void setOperations(); void stlIterator(); void stlMutableIterator(); @@ -577,21 +576,6 @@ void tst_QSet::insert() } } -void tst_QSet::reverseIterators() -{ - QSet s; - s << 1 << 17 << 61 << 127 << 911; - std::vector v(s.begin(), s.end()); - std::reverse(v.begin(), v.end()); - const QSet &cs = s; - QVERIFY(std::equal(v.begin(), v.end(), s.rbegin())); - QVERIFY(std::equal(v.begin(), v.end(), s.crbegin())); - QVERIFY(std::equal(v.begin(), v.end(), cs.rbegin())); - QVERIFY(std::equal(s.rbegin(), s.rend(), v.begin())); - QVERIFY(std::equal(s.crbegin(), s.crend(), v.begin())); - QVERIFY(std::equal(cs.rbegin(), cs.rend(), v.begin())); -} - void tst_QSet::setOperations() { QSet set1, set2; @@ -705,16 +689,6 @@ void tst_QSet::stlIterator() } QVERIFY(sum == 24999 * 25000 / 2); } - - { - int sum = 0; - QSet::const_iterator i = set1.end(); - while (i != set1.begin()) { - --i; - sum += toNumber(*i); - } - QVERIFY(sum == 24999 * 25000 / 2); - } } void tst_QSet::stlMutableIterator() @@ -733,22 +707,11 @@ void tst_QSet::stlMutableIterator() QVERIFY(sum == 24999 * 25000 / 2); } - { - int sum = 0; - QSet::iterator i = set1.end(); - while (i != set1.begin()) { - --i; - sum += toNumber(*i); - } - QVERIFY(sum == 24999 * 25000 / 2); - } - { QSet set2 = set1; QSet set3 = set2; QSet::iterator i = set2.begin(); - QSet::iterator j = set3.begin(); while (i != set2.end()) { i = set2.erase(i); @@ -756,24 +719,7 @@ void tst_QSet::stlMutableIterator() QVERIFY(set2.isEmpty()); QVERIFY(!set3.isEmpty()); - j = set3.end(); - while (j != set3.begin()) { - j--; - if (j + 1 != set3.end()) - set3.erase(j + 1); - } - if (set3.begin() != set3.end()) - set3.erase(set3.begin()); - - QVERIFY(set2.isEmpty()); - QVERIFY(set3.isEmpty()); - -// #if QT_VERSION >= 0x050000 -// i = set2.insert("foo"); -// #else - QSet::const_iterator k = set2.insert("foo"); - i = reinterpret_cast::iterator &>(k); -// #endif + i = set2.insert("foo"); QCOMPARE(*i, QLatin1String("foo")); } } @@ -802,47 +748,6 @@ void tst_QSet::javaIterator() QVERIFY(sum == 24999 * 25000 / 2); } - { - int sum = 0; - QSetIterator i(set1); - while (i.hasNext()) { - i.next(); - sum += toNumber(i.peekPrevious()); - } - QVERIFY(sum == 24999 * 25000 / 2); - } - - { - int sum = 0; - QSetIterator i(set1); - i.toBack(); - while (i.hasPrevious()) - sum += toNumber(i.previous()); - QVERIFY(sum == 24999 * 25000 / 2); - } - - { - int sum = 0; - QSetIterator i(set1); - i.toBack(); - while (i.hasPrevious()) { - sum += toNumber(i.peekPrevious()); - i.previous(); - } - QVERIFY(sum == 24999 * 25000 / 2); - } - - { - int sum = 0; - QSetIterator i(set1); - i.toBack(); - while (i.hasPrevious()) { - i.previous(); - sum += toNumber(i.peekNext()); - } - QVERIFY(sum == 24999 * 25000 / 2); - } - int sum1 = 0; int sum2 = 0; QSetIterator i(set1); @@ -896,53 +801,11 @@ void tst_QSet::javaMutableIterator() QVERIFY(sum == 24999 * 25000 / 2); } - { - int sum = 0; - QMutableSetIterator i(set1); - while (i.hasNext()) { - i.next(); - sum += toNumber(i.peekPrevious()); - } - QVERIFY(sum == 24999 * 25000 / 2); - } - - { - int sum = 0; - QMutableSetIterator i(set1); - i.toBack(); - while (i.hasPrevious()) - sum += toNumber(i.previous()); - QVERIFY(sum == 24999 * 25000 / 2); - } - - { - int sum = 0; - QMutableSetIterator i(set1); - i.toBack(); - while (i.hasPrevious()) { - sum += toNumber(i.peekPrevious()); - i.previous(); - } - QVERIFY(sum == 24999 * 25000 / 2); - } - - { - int sum = 0; - QMutableSetIterator i(set1); - i.toBack(); - while (i.hasPrevious()) { - i.previous(); - sum += toNumber(i.peekNext()); - } - QVERIFY(sum == 24999 * 25000 / 2); - } - { QSet set2 = set1; QSet set3 = set2; QMutableSetIterator i(set2); - QMutableSetIterator j(set3); while (i.hasNext()) { i.next(); @@ -950,14 +813,6 @@ void tst_QSet::javaMutableIterator() } QVERIFY(set2.isEmpty()); QVERIFY(!set3.isEmpty()); - - j.toBack(); - while (j.hasPrevious()) { - j.previous(); - j.remove(); - } - QVERIFY(set2.isEmpty()); - QVERIFY(set3.isEmpty()); } } -- cgit v1.2.3 From dca3d467a7545f3012d05aa027f2865f6b857a3f Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 20 Jan 2020 17:45:38 +0100 Subject: Don't enforce C++11 We require C++17 in Qt6 Change-Id: I2dde485524208a1c7131869f4267f44ad2b32e9f Reviewed-by: Simon Hausmann --- tests/auto/corelib/tools/qoffsetstringarray/qoffsetstringarray.pro | 1 - 1 file changed, 1 deletion(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/tools/qoffsetstringarray/qoffsetstringarray.pro b/tests/auto/corelib/tools/qoffsetstringarray/qoffsetstringarray.pro index c8e6a8e05a..6c00f4f081 100644 --- a/tests/auto/corelib/tools/qoffsetstringarray/qoffsetstringarray.pro +++ b/tests/auto/corelib/tools/qoffsetstringarray/qoffsetstringarray.pro @@ -1,6 +1,5 @@ CONFIG += testcase TARGET = tst_qoffsetstringarray QT = core testlib core-private -CONFIG += c++11 CONFIG += strict_c++ SOURCES = $$PWD/tst_qoffsetstringarray.cpp -- cgit v1.2.3 From d5669a48549eaf53163a5ce629326ea763d01941 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 24 Jan 2020 08:29:51 +0100 Subject: Fix tests in QHash that would read beyond end() A couple of tests in the QHash autotest could iterate beyond end(), leading to undefined behavior. This is bound to crash with the new upcoming QHash implementation. Change-Id: I977fc939e6e472f05b7cb2fa0a79c2d5f8782f45 Reviewed-by: Simon Hausmann --- tests/auto/corelib/tools/qhash/tst_qhash.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/tools/qhash/tst_qhash.cpp b/tests/auto/corelib/tools/qhash/tst_qhash.cpp index 5dc1800569..4052eff0ae 100644 --- a/tests/auto/corelib/tools/qhash/tst_qhash.cpp +++ b/tests/auto/corelib/tools/qhash/tst_qhash.cpp @@ -1080,7 +1080,15 @@ void tst_QHash::keyIterator() QVERIFY(key_it != hash.keyEnd()); QCOMPARE(*key_it, it.key()); QCOMPARE(*(key_it++), (it++).key()); - QCOMPARE(*(++key_it), (++it).key()); + if (key_it != hash.keyEnd()) { + QVERIFY(it != hash.end()); + ++key_it; + ++it; + if (key_it != hash.keyEnd()) + QCOMPARE(*key_it, it.key()); + else + QVERIFY(it == hash.end()); + } QCOMPARE(std::count(hash.keyBegin(), hash.keyEnd(), 99), 1); @@ -1125,7 +1133,10 @@ void tst_QHash::keyValueIterator() ++it; ++key_value_it; - QCOMPARE(*key_value_it, entry_type(it.key(), it.value())); + if (it != hash.end()) + QCOMPARE(*key_value_it, entry_type(it.key(), it.value())); + else + QVERIFY(key_value_it == hash.constKeyValueEnd()); key = 99; value = 99 * 100; -- cgit v1.2.3 From 1b3075dfcb10127951a33595838a98a587d72e04 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Sat, 25 Jan 2020 22:57:24 +0100 Subject: Split QHash and QMultiHash in auto test Change-Id: I0f31feaca740abe33f36a8c117d64447ddcc8043 Reviewed-by: Simon Hausmann --- .../serialization/qdatastream/tst_qdatastream.cpp | 67 +++++++++++++++++++--- 1 file changed, 60 insertions(+), 7 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp b/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp index 29cff8b469..877de3f95d 100644 --- a/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp +++ b/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp @@ -124,6 +124,9 @@ private slots: void stream_Hash_data(); void stream_Hash(); + void stream_MultiHash_data(); + void stream_MultiHash(); + void stream_qint64_data(); void stream_qint64(); @@ -231,6 +234,7 @@ private: #endif void writeMap(QDataStream* dev); void writeHash(QDataStream* dev); + void writeMultiHash(QDataStream* dev); void writeqint64(QDataStream *s); void writeQIcon(QDataStream *s); void writeQEasingCurve(QDataStream *s); @@ -263,6 +267,7 @@ private: #endif void readMap(QDataStream *s); void readHash(QDataStream *s); + void readMultiHash(QDataStream *s); void readqint64(QDataStream *s); void readQIcon(QDataStream *s); void readQEasingCurve(QDataStream *s); @@ -706,16 +711,10 @@ static Hash HashData(int index) map.insert(2, "bbb"); map.insert(3, "cccccc"); break; - case 2: - map.insert(1, "a"); - map.insert(2, "one"); - map.insertMulti(2, "two"); - map.insertMulti(2, "three"); - map.insert(3, "cccccc"); } return map; } -#define MAX_HASH_DATA 3 +#define MAX_HASH_DATA 2 void tst_QDataStream::stream_Hash_data() { @@ -745,6 +744,60 @@ void tst_QDataStream::readHash(QDataStream *s) QCOMPARE(S, test); } +typedef QMultiHash MultiHash; + +static MultiHash MultiHashData(int index) +{ + MultiHash map; + + switch (index) { + case 0: + default: + break; + case 1: + map.insert(1, "a"); + map.insert(2, "bbb"); + map.insert(3, "cccccc"); + break; + case 2: + map.insert(1, "a"); + map.insert(2, "one"); + map.insert(2, "two"); + map.insert(2, "three"); + map.insert(3, "cccccc"); + } + return map; +} +#define MAX_MULTIHASH_DATA 3 + +void tst_QDataStream::stream_MultiHash_data() +{ + stream_data(MAX_HASH_DATA); +} + +void tst_QDataStream::stream_MultiHash() +{ + STREAM_IMPL(MultiHash); +} + +void tst_QDataStream::writeMultiHash(QDataStream* s) +{ + MultiHash test(MultiHashData(dataIndex(QTest::currentDataTag()))); + *s << test; + *s << test; +} + +void tst_QDataStream::readMultiHash(QDataStream *s) +{ + MultiHash S; + MultiHash test(MultiHashData(dataIndex(QTest::currentDataTag()))); + + *s >> S; + QCOMPARE(S, test); + *s >> S; + QCOMPARE(S, test); +} + // ************************************ static QEasingCurve QEasingCurveData(int index) -- cgit v1.2.3 From 8020a5279359097fe7d61fcc26ef89db4079aea0 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Sat, 25 Jan 2020 22:27:16 +0100 Subject: Adjust QVariant autotest to prepare for upcoming QHash changes QHash won't contain an insertMulti() method anymore. Change-Id: I507e76d496c3a33a6e88d15aa30df06c07eeba9f Reviewed-by: Simon Hausmann --- .../auto/corelib/kernel/qvariant/tst_qvariant.cpp | 28 ++++------------------ 1 file changed, 4 insertions(+), 24 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp index 9f022b3b14..91733bea90 100644 --- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp +++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp @@ -2279,16 +2279,6 @@ void tst_QVariant::variantMap() QCOMPARE(qvariant_cast(v3).value("test").toInt(), 42); QCOMPARE(v, QVariant(v.toHash())); - - // multi-keys - map.insertMulti("test", 47); - v = map; - map2 = qvariant_cast(v); - QCOMPARE(map2, map); - map2 = v.toMap(); - QCOMPARE(map2, map); - - QCOMPARE(v, QVariant(v.toHash())); } void tst_QVariant::variantHash() @@ -2312,16 +2302,6 @@ void tst_QVariant::variantHash() QCOMPARE(qvariant_cast(v3).value("test").toInt(), 42); QCOMPARE(v, QVariant(v.toMap())); - - // multi-keys - hash.insertMulti("test", 47); - v = hash; - hash2 = qvariant_cast(v); - QCOMPARE(hash2, hash); - hash2 = v.toHash(); - QCOMPARE(hash2, hash); - - QCOMPARE(v, QVariant(v.toMap())); } class CustomQObject : public QObject { @@ -3063,7 +3043,7 @@ void tst_QVariant::convertIterables() const QCOMPARE(QVariant::fromValue(map).value().count(), map.count()); QCOMPARE(QVariant::fromValue(map).value().count(), map.count()); - map.insertMulti("3", 5); + map.insert("4", 5); QCOMPARE(QVariant::fromValue(map).value().count(), map.count()); QCOMPARE(QVariant::fromValue(map).value().count(), map.count()); } @@ -3073,7 +3053,7 @@ void tst_QVariant::convertIterables() const QCOMPARE(QVariant::fromValue(map).value().count(), map.count()); QCOMPARE(QVariant::fromValue(map).value().count(), map.count()); - map.insertMulti("3", 5); + map.insert("4", 5); QCOMPARE(QVariant::fromValue(map).value().count(), map.count()); QCOMPARE(QVariant::fromValue(map).value().count(), map.count()); } @@ -3083,7 +3063,7 @@ void tst_QVariant::convertIterables() const QCOMPARE(QVariant::fromValue(hash).value().count(), hash.count()); QCOMPARE(QVariant::fromValue(hash).value().count(), hash.count()); - hash.insertMulti("3", 5); + hash.insert("4", 5); QCOMPARE(QVariant::fromValue(hash).value().count(), hash.count()); QCOMPARE(QVariant::fromValue(hash).value().count(), hash.count()); } @@ -3093,7 +3073,7 @@ void tst_QVariant::convertIterables() const QCOMPARE(QVariant::fromValue(hash).value().count(), hash.count()); QCOMPARE(QVariant::fromValue(hash).value().count(), hash.count()); - hash.insertMulti("3", 5); + hash.insert("4", 5); QCOMPARE(QVariant::fromValue(hash).value().count(), hash.count()); QCOMPARE(QVariant::fromValue(hash).value().count(), hash.count()); } -- cgit v1.2.3 From daf1f3f9ced82f139adbd7fd55b9288aa661b3e6 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 28 Jan 2020 12:50:20 +0100 Subject: Fix a few test cases to not rely on QMultiHash only API for QHash Change-Id: If4a741adec6f93d14bd5b21baa1dd062b49898ec Reviewed-by: Simon Hausmann --- tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp | 2 +- tests/auto/widgets/itemviews/qdirmodel/tst_qdirmodel.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp index 7398cc103e..4e31c3e57c 100644 --- a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp +++ b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp @@ -1063,7 +1063,7 @@ void tst_QFileSystemModel::roleNames() QVERIFY(roles.contains(role)); QFETCH(QByteArray, roleName); - QCOMPARE(roles.values(role).count(), 1); + QCOMPARE(roles.contains(role), true); QCOMPARE(roles.value(role), roleName); } diff --git a/tests/auto/widgets/itemviews/qdirmodel/tst_qdirmodel.cpp b/tests/auto/widgets/itemviews/qdirmodel/tst_qdirmodel.cpp index 546b2ab3a8..925c578300 100644 --- a/tests/auto/widgets/itemviews/qdirmodel/tst_qdirmodel.cpp +++ b/tests/auto/widgets/itemviews/qdirmodel/tst_qdirmodel.cpp @@ -713,7 +713,7 @@ void tst_QDirModel::roleNames() QVERIFY(roles.contains(role)); QFETCH(QByteArray, roleName); - QCOMPARE(roles.values(role).count(), 1); + QCOMPARE(roles.contains(role), true); QCOMPARE(roles.value(role), roleName); } -- cgit v1.2.3 From ed080c64ae21d22115d16780a5903d7cc4fd1546 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 21 Jan 2020 13:23:34 +0100 Subject: Core: Add a QTypeRevision class QTypeRevision is needed to encode the value of the new two-argument Q_REVISION(major, minor) macros. Those, in turn are necessary because the minor version resets to 0, and we need to take the major version into account when stating revisions for Qt classes. Task-number: QTBUG-71278 Change-Id: I63eff6eab7d6e4f8f32b359a216767c98947a106 Reviewed-by: Fabian Kosmale Reviewed-by: Paul Wicking Reviewed-by: Simon Hausmann Reviewed-by: Lars Knoll Reviewed-by: Thiago Macieira Reviewed-by: Shawn Rutledge --- .../tools/qversionnumber/tst_qversionnumber.cpp | 115 +++++++++++++++++++++ 1 file changed, 115 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/corelib/tools/qversionnumber/tst_qversionnumber.cpp b/tests/auto/corelib/tools/qversionnumber/tst_qversionnumber.cpp index 7c4d1071ce..63a6618dab 100644 --- a/tests/auto/corelib/tools/qversionnumber/tst_qversionnumber.cpp +++ b/tests/auto/corelib/tools/qversionnumber/tst_qversionnumber.cpp @@ -81,6 +81,9 @@ private slots: void serialize(); void moveSemantics(); void qtVersion(); + void qPropertyRevision_data(); + void qPropertyRevision(); + void qPropertyRevisionTypes(); }; void tst_QVersionNumber::singleInstanceData() @@ -645,6 +648,118 @@ void tst_QVersionNumber::qtVersion() QCOMPARE(v.toString(), QString(qVersion())); } +template +void compileTestRevisionMajorMinor() +{ + const Integer major = 8; + const Integer minor = 4; + + const QTypeRevision r2 = QTypeRevision::fromVersion(major, minor); + QCOMPARE(r2.majorVersion(), 8); + QCOMPARE(r2.minorVersion(), 4); + + const QTypeRevision r3 = QTypeRevision::fromMajorVersion(major); + QCOMPARE(r3.majorVersion(), 8); + QVERIFY(!r3.hasMinorVersion()); + + const QTypeRevision r4 = QTypeRevision::fromMinorVersion(minor); + QVERIFY(!r4.hasMajorVersion()); + QCOMPARE(r4.minorVersion(), 4); +} + + +template +void compileTestRevision() +{ + if (std::is_signed::value) + compileTestRevision::Signed>(); + else + compileTestRevision::Unsigned>(); + + const Integer value = 0x0510; + const QTypeRevision r = QTypeRevision::fromEncodedVersion(value); + + QCOMPARE(r.majorVersion(), 5); + QCOMPARE(r.minorVersion(), 16); + QCOMPARE(r.toEncodedVersion(), value); + + compileTestRevisionMajorMinor(); +} + +template<> +void compileTestRevision() +{ + compileTestRevisionMajorMinor(); +} + +template<> +void compileTestRevision() +{ + compileTestRevisionMajorMinor(); +} + +template<> +void compileTestRevision() +{ + compileTestRevisionMajorMinor(); +} + +void tst_QVersionNumber::qPropertyRevision_data() +{ + QTest::addColumn("revision"); + QTest::addColumn("valid"); + QTest::addColumn("major"); + QTest::addColumn("minor"); + + QTest::addRow("Qt revision") << QTypeRevision::fromVersion(QT_VERSION_MAJOR, QT_VERSION_MINOR) + << true << QT_VERSION_MAJOR << QT_VERSION_MINOR; + QTest::addRow("invalid") << QTypeRevision() << false << 0xff << 0xff; + QTest::addRow("major") << QTypeRevision::fromMajorVersion(6) << true << 6 << 0xff; + QTest::addRow("minor") << QTypeRevision::fromMinorVersion(15) << true << 0xff << 15; + QTest::addRow("zero") << QTypeRevision::fromVersion(0, 0) << true << 0 << 0; + + // We're intentionally not testing negative numbers. + // There are asserts against negative numbers in QTypeRevision. + // You must not pass them as major or minor versions, or values. +} + +void tst_QVersionNumber::qPropertyRevision() +{ + const QTypeRevision other = QTypeRevision::fromVersion(127, 128); + + QFETCH(QTypeRevision, revision); + + QFETCH(bool, valid); + QFETCH(int, major); + QFETCH(int, minor); + + QCOMPARE(revision.isValid(), valid); + QCOMPARE(revision.majorVersion(), major); + QCOMPARE(revision.minorVersion(), minor); + + QCOMPARE(revision.hasMajorVersion(), QTypeRevision::isValidSegment(major)); + QCOMPARE(revision.hasMinorVersion(), QTypeRevision::isValidSegment(minor)); + + const QTypeRevision copy = QTypeRevision::fromEncodedVersion(revision.toEncodedVersion()); + QCOMPARE(copy, revision); + + QVERIFY(revision != other); + QVERIFY(copy != other); +} + +void tst_QVersionNumber::qPropertyRevisionTypes() +{ + compileTestRevision(); + compileTestRevision(); + + QVERIFY(!QTypeRevision::isValidSegment(0xff)); + QVERIFY(!QTypeRevision::isValidSegment(-1)); + + const QTypeRevision maxRevision = QTypeRevision::fromVersion(254, 254); + QVERIFY(maxRevision.hasMajorVersion()); + QVERIFY(maxRevision.hasMinorVersion()); +} + QTEST_APPLESS_MAIN(tst_QVersionNumber) #include "tst_qversionnumber.moc" -- cgit v1.2.3 From d5bb8d5150498dc059e8c17f224c66fb1a6bcf32 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Wed, 15 Jan 2020 13:14:20 +0100 Subject: Preserve the case of the exponent separator CLDR supplies We have long (since 4.5.1) coerced it to lower-case, for no readily apparent, much less documented, reason. CLDR says most locales use an upper-case E for this - let's actually use what CLDR says we should use. The code that matches the exponent separator was doing so case-insensitively in any case; that needed adaptation now that the separator's case isn't pre-determined; and, in any case, should have been done using case-folding rather than upper-casing. In the process, removed some spurious checks for "'e' or 'E'" in the result, since the exponent separator is always represented by 'e' (and an 'e' might also be present for the separate reason of its use as a beyond-decimal digit representing fourteen). [ChangeLog][QtCore][QLocale] QLocale::exponential() now preserves the case of the CLDR source, where previously it was lower-cased. Change-Id: Ic9ac02136cff79cb9f136d72141b5dbf54d9e0a6 Reviewed-by: Lars Knoll --- .../serialization/qtextstream/tst_qtextstream.cpp | 6 +++--- tests/auto/corelib/text/qlocale/tst_qlocale.cpp | 20 ++++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/serialization/qtextstream/tst_qtextstream.cpp b/tests/auto/corelib/serialization/qtextstream/tst_qtextstream.cpp index 6381ce5ed0..6565924f58 100644 --- a/tests/auto/corelib/serialization/qtextstream/tst_qtextstream.cpp +++ b/tests/auto/corelib/serialization/qtextstream/tst_qtextstream.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. @@ -2449,8 +2449,8 @@ void tst_QTextStream::generateRealNumbersDataWrite() QTest::newRow("0") << 0.0 << QByteArray("0") << QByteArray("0"); QTest::newRow("3.14") << 3.14 << QByteArray("3.14") << QByteArray("3.14"); QTest::newRow("-3.14") << -3.14 << QByteArray("-3.14") << QByteArray("-3.14"); - QTest::newRow("1.2e+10") << 1.2e+10 << QByteArray("1.2e+10") << QByteArray("1.2e+10"); - QTest::newRow("-1.2e+10") << -1.2e+10 << QByteArray("-1.2e+10") << QByteArray("-1.2e+10"); + QTest::newRow("1.2e+10") << 1.2e+10 << QByteArray("1.2e+10") << QByteArray("1.2E+10"); + QTest::newRow("-1.2e+10") << -1.2e+10 << QByteArray("-1.2e+10") << QByteArray("-1.2E+10"); QTest::newRow("12345") << 12345. << QByteArray("12345") << QByteArray("12,345"); } diff --git a/tests/auto/corelib/text/qlocale/tst_qlocale.cpp b/tests/auto/corelib/text/qlocale/tst_qlocale.cpp index 7b2d92f9cb..f56414331a 100644 --- a/tests/auto/corelib/text/qlocale/tst_qlocale.cpp +++ b/tests/auto/corelib/text/qlocale/tst_qlocale.cpp @@ -1060,8 +1060,8 @@ void tst_QLocale::doubleToString_data() QTest::newRow("de_DE 3,4 f 1") << QString("de_DE") << QString("3,4") << 3.4 << 'f' << 1; QTest::newRow("de_DE 3,4 f -") << QString("de_DE") << QString("3,4") << 3.4 << 'f' << shortest; - QTest::newRow("de_DE 3,4 e 1") << QString("de_DE") << QString("3,4e+00") << 3.4 << 'e' << 1; - QTest::newRow("de_DE 3,4 e -") << QString("de_DE") << QString("3,4e+00") << 3.4 << 'e' << shortest; + QTest::newRow("de_DE 3,4 e 1") << QString("de_DE") << QString("3,4E+00") << 3.4 << 'e' << 1; + QTest::newRow("de_DE 3,4 e -") << QString("de_DE") << QString("3,4E+00") << 3.4 << 'e' << shortest; QTest::newRow("de_DE 3,4 g 2") << QString("de_DE") << QString("3,4") << 3.4 << 'g' << 2; QTest::newRow("de_DE 3,4 g -") << QString("de_DE") << QString("3,4") << 3.4 << 'g' << shortest; @@ -1081,8 +1081,8 @@ void tst_QLocale::doubleToString_data() QTest::newRow("de_DE 0,035003945 f 9") << QString("de_DE") << QString("0,035003945") << 0.035003945 << 'f' << 9; QTest::newRow("de_DE 0,035003945 f -") << QString("de_DE") << QString("0,035003945") << 0.035003945 << 'f' << shortest; - QTest::newRow("de_DE 0,035003945 e 7") << QString("de_DE") << QString("3,5003945e-02") << 0.035003945 << 'e' << 7; - QTest::newRow("de_DE 0,035003945 e -") << QString("de_DE") << QString("3,5003945e-02") << 0.035003945 << 'e' << shortest; + QTest::newRow("de_DE 0,035003945 e 7") << QString("de_DE") << QString("3,5003945E-02") << 0.035003945 << 'e' << 7; + QTest::newRow("de_DE 0,035003945 e -") << QString("de_DE") << QString("3,5003945E-02") << 0.035003945 << 'e' << shortest; QTest::newRow("de_DE 0,035003945 g 8") << QString("de_DE") << QString("0,035003945") << 0.035003945 << 'g' << 8; QTest::newRow("de_DE 0,035003945 g -") << QString("de_DE") << QString("0,035003945") << 0.035003945 << 'g' << shortest; @@ -1102,10 +1102,10 @@ void tst_QLocale::doubleToString_data() QTest::newRow("de_DE 0,000003945 f 9") << QString("de_DE") << QString("0,000003945") << 0.000003945 << 'f' << 9; QTest::newRow("de_DE 0,000003945 f -") << QString("de_DE") << QString("0,000003945") << 0.000003945 << 'f' << shortest; - QTest::newRow("de_DE 0,000003945 e 3") << QString("de_DE") << QString("3,945e-06") << 0.000003945 << 'e' << 3; - QTest::newRow("de_DE 0,000003945 e -") << QString("de_DE") << QString("3,945e-06") << 0.000003945 << 'e' << shortest; - QTest::newRow("de_DE 0,000003945 g 4") << QString("de_DE") << QString("3,945e-06") << 0.000003945 << 'g' << 4; - QTest::newRow("de_DE 0,000003945 g -") << QString("de_DE") << QString("3,945e-06") << 0.000003945 << 'g' << shortest; + QTest::newRow("de_DE 0,000003945 e 3") << QString("de_DE") << QString("3,945E-06") << 0.000003945 << 'e' << 3; + QTest::newRow("de_DE 0,000003945 e -") << QString("de_DE") << QString("3,945E-06") << 0.000003945 << 'e' << shortest; + QTest::newRow("de_DE 0,000003945 g 4") << QString("de_DE") << QString("3,945E-06") << 0.000003945 << 'g' << 4; + QTest::newRow("de_DE 0,000003945 g -") << QString("de_DE") << QString("3,945E-06") << 0.000003945 << 'g' << shortest; QTest::newRow("C 12456789012 f 3") << QString("C") << QString("12456789012.000") << 12456789012.0 << 'f' << 3; QTest::newRow("C 12456789012 e 13") << QString("C") << QString("1.2456789012000e+10") << 12456789012.0 << 'e' << 13; @@ -1122,8 +1122,8 @@ void tst_QLocale::doubleToString_data() QTest::newRow("de_DE 12456789012 f 0") << QString("de_DE") << QString("12.456.789.012") << 12456789012.0 << 'f' << 0; QTest::newRow("de_DE 12456789012 f -") << QString("de_DE") << QString("12.456.789.012") << 12456789012.0 << 'f' << shortest; - QTest::newRow("de_DE 12456789012 e 10") << QString("de_DE") << QString("1,2456789012e+10") << 12456789012.0 << 'e' << 10; - QTest::newRow("de_DE 12456789012 e -") << QString("de_DE") << QString("1,2456789012e+10") << 12456789012.0 << 'e' << shortest; + QTest::newRow("de_DE 12456789012 e 10") << QString("de_DE") << QString("1,2456789012E+10") << 12456789012.0 << 'e' << 10; + QTest::newRow("de_DE 12456789012 e -") << QString("de_DE") << QString("1,2456789012E+10") << 12456789012.0 << 'e' << shortest; QTest::newRow("de_DE 12456789012 g 11") << QString("de_DE") << QString("12.456.789.012") << 12456789012.0 << 'g' << 11; QTest::newRow("de_DE 12456789012 g -") << QString("de_DE") << QString("12.456.789.012") << 12456789012.0 << 'g' << shortest; } -- cgit v1.2.3 From 264ed73052513015caafaf146286cf63aaa68b03 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Wed, 15 Jan 2020 16:54:20 +0100 Subject: Move old tst_QLocale::negativeZero() to tst_QString::number() It was more complex than it needed to be and was a test of QString, not of QLocale. This leaves tst_QLocale::negativeZero() available to now test how QLocale handles negative zero. Change-Id: Ic9aae250c29f579e6d60fba8404b38673a3b489f Reviewed-by: Lars Knoll --- tests/auto/corelib/text/qlocale/tst_qlocale.cpp | 28 ++++++++++++++++++++----- tests/auto/corelib/text/qstring/tst_qstring.cpp | 15 ++++++------- 2 files changed, 31 insertions(+), 12 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/text/qlocale/tst_qlocale.cpp b/tests/auto/corelib/text/qlocale/tst_qlocale.cpp index f56414331a..f19b66be37 100644 --- a/tests/auto/corelib/text/qlocale/tst_qlocale.cpp +++ b/tests/auto/corelib/text/qlocale/tst_qlocale.cpp @@ -59,6 +59,7 @@ #endif Q_DECLARE_METATYPE(QLocale::FormatType) +Q_DECLARE_METATYPE(QStringView) class tst_QLocale : public QObject { @@ -95,6 +96,7 @@ private slots: void long_long_conversion_extra(); void testInfAndNan(); void fpExceptions(); + void negativeZero_data(); void negativeZero(); void dayOfWeek(); void dayOfWeek_data(); @@ -1422,13 +1424,29 @@ void tst_QLocale::fpExceptions() #endif } +void tst_QLocale::negativeZero_data() +{ + QTest::addColumn("language"); + QTest::addColumn("script"); + QTest::addColumn("territory"); + QTest::addColumn("expect"); + + QTest::newRow("C") + << QLocale::C << QLocale::AnyScript << QLocale::AnyCountry + << QStringView(u"0"); + QTest::newRow("Arabic") + << QLocale::Arabic << QLocale::ArabicScript << QLocale::AnyCountry + << QStringView(u"\u0660"); +} + void tst_QLocale::negativeZero() { - double negativeZero( 0.0 ); // Initialise to zero. - uchar *ptr = (uchar *)&negativeZero; - ptr[QSysInfo::ByteOrder == QSysInfo::BigEndian ? 0 : 7] = 0x80; - QString s = QString::number(negativeZero); - QCOMPARE(s, QString("0")); + QFETCH(QLocale::Language, language); + QFETCH(QLocale::Script, script); + QFETCH(QLocale::Country, territory); + QFETCH(QStringView, expect); + QLocale locale(language, script, territory); + QCOMPARE(locale.toString(std::copysign(0.0, -1.0)), expect); } void tst_QLocale::dayOfWeek_data() diff --git a/tests/auto/corelib/text/qstring/tst_qstring.cpp b/tests/auto/corelib/text/qstring/tst_qstring.cpp index e5b5e526de..ca58b664a0 100644 --- a/tests/auto/corelib/text/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/text/qstring/tst_qstring.cpp @@ -4927,13 +4927,14 @@ void tst_QString::arg() void tst_QString::number() { - QCOMPARE( QString::number(int(0)), QLatin1String("0") ); - QCOMPARE( QString::number((unsigned int)(11)), QLatin1String("11") ); - QCOMPARE( QString::number(-22L), QLatin1String("-22") ); - QCOMPARE( QString::number(333UL), QLatin1String("333") ); - QCOMPARE( QString::number(4.4), QLatin1String("4.4") ); - QCOMPARE( QString::number(Q_INT64_C(-555)), QLatin1String("-555") ); - QCOMPARE( QString::number(Q_UINT64_C(6666)), QLatin1String("6666") ); + QCOMPARE(QString::number(int(0)), QLatin1String("0")); + QCOMPARE(QString::number(std::copysign(0.0, -1.0)), QLatin1String("0")); + QCOMPARE(QString::number((unsigned int)(11)), QLatin1String("11")); + QCOMPARE(QString::number(-22L), QLatin1String("-22")); + QCOMPARE(QString::number(333UL), QLatin1String("333")); + QCOMPARE(QString::number(4.4), QLatin1String("4.4")); + QCOMPARE(QString::number(Q_INT64_C(-555)), QLatin1String("-555")); + QCOMPARE(QString::number(Q_UINT64_C(6666)), QLatin1String("6666")); #ifndef QT_NO_DOUBLECONVERSION // snprintf_l is too stupid for this QCOMPARE( QString::number(12.05, 'f', 1), QString("12.1") ); -- cgit v1.2.3 From 0b325602b13e2af21e888fc2243541e528cbb4b8 Mon Sep 17 00:00:00 2001 From: Vitaly Fanaskov Date: Fri, 31 Jan 2020 15:20:41 +0100 Subject: QButtonGroup: remove deprecated signals Task-number: QTBUG-80906 Change-Id: I6f697b0a070ba4c401117fe7cdf02429b47d9a11 Reviewed-by: Christian Ehrlicher --- .../widgets/qbuttongroup/tst_qbuttongroup.cpp | 37 +++------------------- 1 file changed, 5 insertions(+), 32 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp b/tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp index 47dfc86a69..5d52acd1a2 100644 --- a/tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp +++ b/tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp @@ -280,67 +280,43 @@ void tst_QButtonGroup::testSignals() qRegisterMetaType("QAbstractButton *"); QSignalSpy clickedSpy(&buttons, SIGNAL(buttonClicked(QAbstractButton*))); - QSignalSpy clickedIdSpy(&buttons, SIGNAL(buttonClicked(int))); QSignalSpy pressedSpy(&buttons, SIGNAL(buttonPressed(QAbstractButton*))); - QSignalSpy pressedIdSpy(&buttons, SIGNAL(buttonPressed(int))); QSignalSpy releasedSpy(&buttons, SIGNAL(buttonReleased(QAbstractButton*))); - QSignalSpy releasedIdSpy(&buttons, SIGNAL(buttonReleased(int))); pb1.animateClick(); QTestEventLoop::instance().enterLoop(1); QCOMPARE(clickedSpy.count(), 1); - QCOMPARE(clickedIdSpy.count(), 1); - int expectedId = -2; - - QCOMPARE(clickedIdSpy.takeFirst().at(0).toInt(), expectedId); QCOMPARE(pressedSpy.count(), 1); - QCOMPARE(pressedIdSpy.count(), 1); - QCOMPARE(pressedIdSpy.takeFirst().at(0).toInt(), expectedId); QCOMPARE(releasedSpy.count(), 1); - QCOMPARE(releasedIdSpy.count(), 1); - QCOMPARE(releasedIdSpy.takeFirst().at(0).toInt(), expectedId); clickedSpy.clear(); - clickedIdSpy.clear(); pressedSpy.clear(); - pressedIdSpy.clear(); releasedSpy.clear(); - releasedIdSpy.clear(); pb2.animateClick(); QTestEventLoop::instance().enterLoop(1); QCOMPARE(clickedSpy.count(), 1); - QCOMPARE(clickedIdSpy.count(), 1); - QCOMPARE(clickedIdSpy.takeFirst().at(0).toInt(), 23); QCOMPARE(pressedSpy.count(), 1); - QCOMPARE(pressedIdSpy.count(), 1); - QCOMPARE(pressedIdSpy.takeFirst().at(0).toInt(), 23); QCOMPARE(releasedSpy.count(), 1); - QCOMPARE(releasedIdSpy.count(), 1); - QCOMPARE(releasedIdSpy.takeFirst().at(0).toInt(), 23); QSignalSpy toggledSpy(&buttons, SIGNAL(buttonToggled(QAbstractButton*, bool))); - QSignalSpy toggledIdSpy(&buttons, SIGNAL(buttonToggled(int, bool))); pb1.setCheckable(true); pb2.setCheckable(true); pb1.toggle(); QCOMPARE(toggledSpy.count(), 1); - QCOMPARE(toggledIdSpy.count(), 1); pb2.toggle(); QCOMPARE(toggledSpy.count(), 3); // equals 3 since pb1 and pb2 are both toggled - QCOMPARE(toggledIdSpy.count(), 3); pb1.setCheckable(false); pb2.setCheckable(false); pb1.toggle(); QCOMPARE(toggledSpy.count(), 3); - QCOMPARE(toggledIdSpy.count(), 3); } void tst_QButtonGroup::task106609() @@ -372,7 +348,6 @@ void tst_QButtonGroup::task106609() qRegisterMetaType("QAbstractButton*"); QSignalSpy spy1(buttons, SIGNAL(buttonClicked(QAbstractButton*))); - QSignalSpy spy2(buttons, SIGNAL(buttonClicked(int))); QApplication::setActiveWindow(&dlg); QTRY_COMPARE(QApplication::activeWindow(), static_cast(&dlg)); @@ -381,8 +356,6 @@ void tst_QButtonGroup::task106609() radio1->setChecked(true); QTestEventLoop::instance().enterLoop(1); - //qDebug() << "int:" << spy2.count() << "QAbstractButton*:" << spy1.count(); - QCOMPARE(spy2.count(), 2); QCOMPARE(spy1.count(), 2); } @@ -427,11 +400,12 @@ public: : group(group) , deleteButton(deleteButton) { - connect(group, SIGNAL(buttonClicked(int)), SLOT(buttonClicked(int))); + connect(group, &QButtonGroup::buttonClicked, + this, &task209485_ButtonDeleter::buttonClicked); } private slots: - void buttonClicked(int) + void buttonClicked() { if (deleteButton) group->removeButton(group->buttons().first()); @@ -447,7 +421,7 @@ void tst_QButtonGroup::task209485_removeFromGroupInEventHandler_data() QTest::addColumn("deleteButton"); QTest::addColumn("signalCount"); QTest::newRow("buttonPress 1") << true << 1; - QTest::newRow("buttonPress 2") << false << 2; + QTest::newRow("buttonPress 2") << false << 1; } void tst_QButtonGroup::task209485_removeFromGroupInEventHandler() @@ -463,12 +437,11 @@ void tst_QButtonGroup::task209485_removeFromGroupInEventHandler() task209485_ButtonDeleter buttonDeleter(&group, deleteButton); QSignalSpy spy1(&group, SIGNAL(buttonClicked(QAbstractButton*))); - QSignalSpy spy2(&group, SIGNAL(buttonClicked(int))); // NOTE: Reintroducing the bug of this task will cause the following line to crash: QTest::mouseClick(button, Qt::LeftButton); - QCOMPARE(spy1.count() + spy2.count(), signalCount); + QCOMPARE(spy1.count(), signalCount); } void tst_QButtonGroup::autoIncrementId() -- cgit v1.2.3 From 4681f1fc2cfabb64b6b4f1095e2d4f44d0cee903 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 17 Jan 2020 14:40:32 +0100 Subject: Separate streaming of QHash and QMultiHash/QMap and QMultiMap Those classes will not have relations anymore in Qt6, so they need separate streaming operators. Writing of multi maps/hashes requires some additional care so that restoring keeps the order of how iteme have been inserted. Change-Id: If41d0c5c24962764a2cb81bd2de9e2fadf1a2b63 Reviewed-by: Simon Hausmann --- .../serialization/qdatastream/tst_qdatastream.cpp | 67 +++++++++++++++++++--- 1 file changed, 60 insertions(+), 7 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp b/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp index 877de3f95d..d1a77173c3 100644 --- a/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp +++ b/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp @@ -121,6 +121,9 @@ private slots: void stream_Map_data(); void stream_Map(); + void stream_MultiMap_data(); + void stream_MultiMap(); + void stream_Hash_data(); void stream_Hash(); @@ -233,6 +236,7 @@ private: void writeQRegularExpression(QDataStream *dev); #endif void writeMap(QDataStream* dev); + void writeMultiMap(QDataStream* dev); void writeHash(QDataStream* dev); void writeMultiHash(QDataStream* dev); void writeqint64(QDataStream *s); @@ -266,6 +270,7 @@ private: void readQRegularExpression(QDataStream *s); #endif void readMap(QDataStream *s); + void readMultiMap(QDataStream *s); void readHash(QDataStream *s); void readMultiHash(QDataStream *s); void readqint64(QDataStream *s); @@ -655,16 +660,10 @@ static Map MapData(int index) map.insert(2, "bbb"); map.insert(3, "cccccc"); break; - case 2: - map.insert(1, "a"); - map.insert(2, "one"); - map.insertMulti(2, "two"); - map.insertMulti(2, "three"); - map.insert(3, "cccccc"); } return map; } -#define MAX_MAP_DATA 3 +#define MAX_MAP_DATA 2 void tst_QDataStream::stream_Map_data() { @@ -694,6 +693,60 @@ void tst_QDataStream::readMap(QDataStream *s) QCOMPARE(S, test); } +typedef QMultiMap MultiMap; + +static MultiMap MultiMapData(int index) +{ + MultiMap map; + + switch (index) { + case 0: + default: + break; + case 1: + map.insert(1, "a"); + map.insert(2, "bbb"); + map.insert(3, "cccccc"); + break; + case 2: + map.insert(1, "a"); + map.insert(2, "one"); + map.insert(2, "two"); + map.insert(2, "three"); + map.insert(3, "cccccc"); + } + return map; +} +#define MAX_MULTIMAP_DATA 3 + +void tst_QDataStream::stream_MultiMap_data() +{ + stream_data(MAX_MULTIMAP_DATA); +} + +void tst_QDataStream::stream_MultiMap() +{ + STREAM_IMPL(MultiMap); +} + +void tst_QDataStream::writeMultiMap(QDataStream* s) +{ + MultiMap test(MultiMapData(dataIndex(QTest::currentDataTag()))); + *s << test; + *s << test; +} + +void tst_QDataStream::readMultiMap(QDataStream *s) +{ + MultiMap S; + MultiMap test(MultiMapData(dataIndex(QTest::currentDataTag()))); + + *s >> S; + QCOMPARE(S, test); + *s >> S; + QCOMPARE(S, test); +} + // ************************************ typedef QHash Hash; -- cgit v1.2.3 From c6e1b54f94e84950ee12c3bb2be0641f5742056b Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 24 Jan 2020 09:09:01 +0100 Subject: Cleanup code where we mixed QHash and QMultiHash iterator code Change-Id: Ib229cad13ca21d6288e009c6ee1c39fa974f80b8 Reviewed-by: Simon Hausmann --- .../tools/qsharedpointer/tst_qsharedpointer.cpp | 30 ++++++++++++---------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp index a9fd282ac9..8a621cd5d9 100644 --- a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp +++ b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp @@ -2155,7 +2155,7 @@ void tst_QSharedPointer::threadStressTest() } } -template +template void hashAndMapTest() { typedef typename Container::key_type Key; @@ -2200,26 +2200,30 @@ void hashAndMapTest() QVERIFY(it == c.end()); } - c.insertMulti(k1, Value(47)); - it = c.find(k1); - QVERIFY(it != c.end()); - QCOMPARE(it.key(), k1); - ++it; - QVERIFY(it != c.end()); - QCOMPARE(it.key(), k1); - ++it; - if (Ordered) - QVERIFY(it == c.end()); + if (Multi) { + c.insert(k1, Value(47)); + it = c.find(k1); + QVERIFY(it != c.end()); + QCOMPARE(it.key(), k1); + ++it; + QVERIFY(it != c.end()); + QCOMPARE(it.key(), k1); + ++it; + if (Ordered) + QVERIFY(it == c.end()); + } } void tst_QSharedPointer::map() { - hashAndMapTest, int>, true>(); + hashAndMapTest, int>, true, false>(); + hashAndMapTest, int>, true, true>(); } void tst_QSharedPointer::hash() { - hashAndMapTest, int>, false>(); + hashAndMapTest, int>, false, false>(); + hashAndMapTest, int>, false, true>(); } void tst_QSharedPointer::validConstructs() -- cgit v1.2.3 From fcaa7506ba1823c5af84341ced3914ea0099b446 Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Fri, 17 Jan 2020 14:15:29 +0100 Subject: Move QOpenGLTextureBlitter from QtGui to QtOpenGL Task-number: QTBUG-74409 Change-Id: Ie4a3dfd01ba44715de6da71c4420fe9a95a0c242 Reviewed-by: Qt CI Bot Reviewed-by: Laszlo Agocs --- tests/auto/gui/qopengl/tst_qopengl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/auto') diff --git a/tests/auto/gui/qopengl/tst_qopengl.cpp b/tests/auto/gui/qopengl/tst_qopengl.cpp index 3a7ad6dad5..cf839e1931 100644 --- a/tests/auto/gui/qopengl/tst_qopengl.cpp +++ b/tests/auto/gui/qopengl/tst_qopengl.cpp @@ -28,6 +28,7 @@ #include #include +#include #include #include #include @@ -40,7 +41,6 @@ #include #include #include -#include #include #include #include -- cgit v1.2.3 From 4c4b5a97c3167b405faab2cc3f3fb38408374df2 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Wed, 5 Feb 2020 16:43:21 +0100 Subject: Skip test cases that is failing on macOS >= 10.14 bind on port 1/82 is now success, in QTcpSocket's test things are more broken: changing the test row makes the test flaky with port not available due to the previous test case. Task-number: QTBUG-81905 Change-Id: Iaf1b5457fa3961a4f6bc92b79aa4668a8359136e Reviewed-by: Timur Pocheptsov --- .../platformsocketengine/tst_platformsocketengine.cpp | 16 +++++++++++----- tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp | 12 +++++++++++- 2 files changed, 22 insertions(+), 6 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/network/socket/platformsocketengine/tst_platformsocketengine.cpp b/tests/auto/network/socket/platformsocketengine/tst_platformsocketengine.cpp index 5be00630ca..1ef9382f0a 100644 --- a/tests/auto/network/socket/platformsocketengine/tst_platformsocketengine.cpp +++ b/tests/auto/network/socket/platformsocketengine/tst_platformsocketengine.cpp @@ -530,11 +530,17 @@ void tst_PlatformSocketEngine::tooManySockets() void tst_PlatformSocketEngine::bind() { #if !defined Q_OS_WIN - PLATFORMSOCKETENGINE binder; - QVERIFY(binder.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol)); - QVERIFY(!binder.bind(QHostAddress::AnyIPv4, 82)); - QCOMPARE(binder.error(), QAbstractSocket::SocketAccessError); -#endif +#if defined Q_OS_MACOS + // On macOS >= 10.14 the bind on this port is successful. + if (QOperatingSystemVersion::current() < QOperatingSystemVersion::MacOSMojave) +#endif // Q_OS_MACOS + { + PLATFORMSOCKETENGINE binder; + QVERIFY(binder.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol)); + QVERIFY(!binder.bind(QHostAddress::AnyIPv4, 82)); + QCOMPARE(binder.error(), QAbstractSocket::SocketAccessError); + } +#endif // Q_OS_WIN PLATFORMSOCKETENGINE binder2; QVERIFY(binder2.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol)); diff --git a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp index 9ab5e88900..bf08d70eb3 100644 --- a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp +++ b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp @@ -558,8 +558,18 @@ void tst_QTcpSocket::bind_data() // try to bind to a privileged ports // we should fail if we're not root (unless the ports are in use!) QTest::newRow("127.0.0.1:1") << "127.0.0.1" << 1 << !geteuid() << (geteuid() ? QString() : "127.0.0.1"); - if (testIpv6) + if (testIpv6) { +#ifdef Q_OS_DARWIN + // This case is faling in different ways, first, it manages to bind to + // port 1 on macOS >= 10.14, but if we change the logic to not fail, + // it's becoming flaky and sometimes fails to bind, with error 'port in use' + // (apparently inflicted by the previous test row with 127.0.0.1). Amen. + if (QOperatingSystemVersion::current() >= QOperatingSystemVersion::MacOSMojave) + QTest::qWarn("Skipping [::]:1, see QTBUG-81905", __FILE__, __LINE__); + else +#endif // Q_OS_DARWIN QTest::newRow("[::]:1") << "::" << 1 << !geteuid() << (geteuid() ? QString() : "::"); + } #endif } -- cgit v1.2.3 From 2145cdc54d5812793310f7e3b3709bfa2648bd50 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 4 Feb 2020 16:07:16 +0100 Subject: Core: Provide comparison functions for QTypeRevision The unspecified segment is between 0 and 1. This is because QTypeRevision::zero(), as the default revisision needs to be smaller than any other. At the same time we want explicitly specified non-zero revisions to be larger than unspecified ones. Breaking this down on a per segment level gives us the order shown here. Change-Id: I1cca12f1180eb6f77563fb5b22c3400e118dc5e9 Reviewed-by: Simon Hausmann --- .../tools/qversionnumber/tst_qversionnumber.cpp | 48 +++++++++++++++++++--- 1 file changed, 42 insertions(+), 6 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/tools/qversionnumber/tst_qversionnumber.cpp b/tests/auto/corelib/tools/qversionnumber/tst_qversionnumber.cpp index 63a6618dab..928bd365fd 100644 --- a/tests/auto/corelib/tools/qversionnumber/tst_qversionnumber.cpp +++ b/tests/auto/corelib/tools/qversionnumber/tst_qversionnumber.cpp @@ -81,9 +81,10 @@ private slots: void serialize(); void moveSemantics(); void qtVersion(); - void qPropertyRevision_data(); - void qPropertyRevision(); - void qPropertyRevisionTypes(); + void qTypeRevision_data(); + void qTypeRevision(); + void qTypeRevisionTypes(); + void qTypeRevisionComparison(); }; void tst_QVersionNumber::singleInstanceData() @@ -704,7 +705,7 @@ void compileTestRevision() compileTestRevisionMajorMinor(); } -void tst_QVersionNumber::qPropertyRevision_data() +void tst_QVersionNumber::qTypeRevision_data() { QTest::addColumn("revision"); QTest::addColumn("valid"); @@ -723,7 +724,7 @@ void tst_QVersionNumber::qPropertyRevision_data() // You must not pass them as major or minor versions, or values. } -void tst_QVersionNumber::qPropertyRevision() +void tst_QVersionNumber::qTypeRevision() { const QTypeRevision other = QTypeRevision::fromVersion(127, 128); @@ -747,7 +748,7 @@ void tst_QVersionNumber::qPropertyRevision() QVERIFY(copy != other); } -void tst_QVersionNumber::qPropertyRevisionTypes() +void tst_QVersionNumber::qTypeRevisionTypes() { compileTestRevision(); compileTestRevision(); @@ -760,6 +761,41 @@ void tst_QVersionNumber::qPropertyRevisionTypes() QVERIFY(maxRevision.hasMinorVersion()); } +void tst_QVersionNumber::qTypeRevisionComparison() +{ + const QTypeRevision revisions[] = { + QTypeRevision::zero(), + QTypeRevision::fromMajorVersion(0), + QTypeRevision::fromVersion(0, 1), + QTypeRevision::fromVersion(0, 20), + QTypeRevision::fromMinorVersion(0), + QTypeRevision(), + QTypeRevision::fromMinorVersion(1), + QTypeRevision::fromMinorVersion(20), + QTypeRevision::fromVersion(1, 0), + QTypeRevision::fromMajorVersion(1), + QTypeRevision::fromVersion(1, 1), + QTypeRevision::fromVersion(1, 20), + QTypeRevision::fromVersion(20, 0), + QTypeRevision::fromMajorVersion(20), + QTypeRevision::fromVersion(20, 1), + QTypeRevision::fromVersion(20, 20), + }; + + const int length = sizeof(revisions) / sizeof(QTypeRevision); + + for (int i = 0; i < length; ++i) { + for (int j = 0; j < length; ++j) { + QCOMPARE(revisions[i] == revisions[j], i == j); + QCOMPARE(revisions[i] != revisions[j], i != j); + QCOMPARE(revisions[i] < revisions[j], i < j); + QCOMPARE(revisions[i] > revisions[j], i > j); + QCOMPARE(revisions[i] <= revisions[j], i <= j); + QCOMPARE(revisions[i] >= revisions[j], i >= j); + } + } +} + QTEST_APPLESS_MAIN(tst_QVersionNumber) #include "tst_qversionnumber.moc" -- cgit v1.2.3 From e14e5e104d17d498378dc24645124900e8c419f4 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Mon, 3 Feb 2020 17:08:57 +0100 Subject: Replace the QMatrix field of QTransform with qreal[3][3] Remove temporarily the reference returned by QTransform::toAffine() since we don't keep the QMatrix object internally anymore. This is done in order to compile the rest of the code. The follow-up patch is going to remove that method completely. Task-number: QTBUG-81628 Change-Id: If7140eedb7582d81ac8da529017cf792174e86ab Reviewed-by: Lars Knoll --- .../gui/painting/qtransform/tst_qtransform.cpp | 63 ---------------------- 1 file changed, 63 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/gui/painting/qtransform/tst_qtransform.cpp b/tests/auto/gui/painting/qtransform/tst_qtransform.cpp index 78638a7518..97c6ad60b8 100644 --- a/tests/auto/gui/painting/qtransform/tst_qtransform.cpp +++ b/tests/auto/gui/painting/qtransform/tst_qtransform.cpp @@ -46,8 +46,6 @@ private slots: void qhash(); void translate(); void scale(); - void matrix(); - void testOffset(); void types(); void types2_data(); void types2(); @@ -372,67 +370,6 @@ void tst_QTransform::scale() QVERIFY( QTransform::fromScale( 1, 1 ) == QTransform()); } -#if QT_DEPRECATED_SINCE(5, 15) -QT_WARNING_PUSH -QT_WARNING_DISABLE_DEPRECATED -void tst_QTransform::matrix() -{ - QMatrix mat1; - mat1.scale(0.3, 0.7); - mat1.translate(53.3, 94.4); - mat1.rotate(45); - - QMatrix mat2; - mat2.rotate(33); - mat2.scale(0.6, 0.6); - mat2.translate(13.333, 7.777); - - QTransform tran1(mat1); - QTransform tran2(mat2); - QTransform dummy; - dummy.setMatrix(mat1.m11(), mat1.m12(), 0, - mat1.m21(), mat1.m22(), 0, - mat1.dx(), mat1.dy(), 1); - - QCOMPARE(tran1, dummy); - QCOMPARE(tran1.inverted(), dummy.inverted()); - QCOMPARE(tran1.inverted(), QTransform(mat1.inverted())); - QCOMPARE(tran2.inverted(), QTransform(mat2.inverted())); - - QMatrix mat3 = mat1 * mat2; - QTransform tran3 = tran1 * tran2; - QCOMPARE(QTransform(mat3), tran3); - - /* QMatrix::operator==() doesn't use qFuzzyCompare(), which - * on win32-g++ results in a failure. So we work around it by - * calling QTranform::operator==(), which performs a fuzzy compare. */ - QCOMPARE(QTransform(mat3), QTransform(tran3.toAffine())); - - QTransform tranInv = tran1.inverted(); - QMatrix matInv = mat1.inverted(); - - QRect rect(43, 70, 200, 200); - QPoint pt(43, 66); - QCOMPARE(tranInv.mapRect(rect), matInv.mapRect(rect)); - QCOMPARE(tranInv.map(pt), matInv.map(pt)); - - QPainterPath path; - path.moveTo(55, 60); - path.lineTo(110, 110); - path.quadTo(220, 50, 10, 20); - path.closeSubpath(); - QCOMPARE(tranInv.map(path), matInv.map(path)); -} - -void tst_QTransform::testOffset() -{ - QTransform trans; - const QMatrix &aff = trans.toAffine(); - QCOMPARE((void*)(&aff), (void*)(&trans)); -} -QT_WARNING_POP -#endif - void tst_QTransform::types() { QTransform m1; -- cgit v1.2.3 From f64694647a9a3d54fa5ecdaf2570e8c7404271a6 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 16 Jan 2020 11:33:41 +0100 Subject: moc: Extend revision markers to allow for major and minor version As we want Qt's own revisions to follow the Qt versioning scheme, we need to allow for the minor version to reset to 0 now. In order to facilitate this, we interpret the argument passed the current Q_REVISION macro as major version and allow for an optional minor version. Both are encoded it into the resulting revision number. Change-Id: I3519fe20233d473f34a24ec9589d045cdd162a12 Reviewed-by: Fawzi Mohamed Reviewed-by: Shawn Rutledge Reviewed-by: Olivier Goffart (Woboq GmbH) --- tests/auto/tools/moc/tst_moc.cpp | 63 +++++++++++++++++++++++++++++++++++----- 1 file changed, 55 insertions(+), 8 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp index a4ee6795c4..be86fc8e21 100644 --- a/tests/auto/tools/moc/tst_moc.cpp +++ b/tests/auto/tools/moc/tst_moc.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include "using-namespaces.h" #include "assign-namespace.h" @@ -1895,12 +1896,14 @@ class VersionTest : public QObject Q_OBJECT Q_PROPERTY(int prop1 READ foo) Q_PROPERTY(int prop2 READ foo REVISION 2) + Q_PROPERTY(int prop514 READ foo REVISION(5, 14)) public: int foo() const { return 0; } Q_INVOKABLE void method1() {} Q_INVOKABLE Q_REVISION(4) void method2() {} + Q_INVOKABLE Q_REVISION(6, 0) void method60() {} enum TestEnum { One, Two }; Q_ENUM(TestEnum); @@ -1909,18 +1912,26 @@ public: public slots: void slot1() {} Q_REVISION(3) void slot2() {} + Q_REVISION(6, 1) void slot61() {} signals: void signal1(); Q_REVISION(5) void signal2(); + Q_REVISION(6, 2) void signal62(); public slots Q_REVISION(6): void slot3() {} void slot4() {} +public slots Q_REVISION(5, 12): + void slot512() {} + signals Q_REVISION(7): void signal3(); void signal4(); + +signals Q_REVISION(5, 15): + void signal515(); }; // If changed, update VersionTest above @@ -1929,12 +1940,14 @@ class VersionTestNotify : public QObject Q_OBJECT Q_PROPERTY(int prop1 READ foo NOTIFY fooChanged) Q_PROPERTY(int prop2 READ foo REVISION 2) + Q_PROPERTY(int prop514 READ foo REVISION(5, 14)) public: int foo() const { return 0; } Q_INVOKABLE void method1() {} Q_INVOKABLE Q_REVISION(4) void method2() {} + Q_INVOKABLE Q_REVISION(6, 0) void method60() {} enum TestEnum { One, Two }; Q_ENUM(TestEnum); @@ -1942,19 +1955,27 @@ public: public slots: void slot1() {} Q_REVISION(3) void slot2() {} + Q_REVISION(6, 1) void slot61() {} signals: void fooChanged(); void signal1(); Q_REVISION(5) void signal2(); + Q_REVISION(6, 2) void signal62(); public slots Q_REVISION(6): void slot3() {} void slot4() {} +public slots Q_REVISION(5, 12): + void slot512() {} + signals Q_REVISION(7): void signal3(); void signal4(); + +signals Q_REVISION(5, 15): + void signal515(); }; template @@ -1963,32 +1984,58 @@ void tst_Moc::revisions_T() int idx = T::staticMetaObject.indexOfProperty("prop1"); QCOMPARE(T::staticMetaObject.property(idx).revision(), 0); idx = T::staticMetaObject.indexOfProperty("prop2"); - QCOMPARE(T::staticMetaObject.property(idx).revision(), 2); + QCOMPARE(T::staticMetaObject.property(idx).revision(), + QTypeRevision::fromMinorVersion(2).toEncodedVersion()); + idx = T::staticMetaObject.indexOfProperty("prop514"); + QCOMPARE(T::staticMetaObject.property(idx).revision(), + QTypeRevision::fromVersion(5, 14).toEncodedVersion()); idx = T::staticMetaObject.indexOfMethod("method1()"); QCOMPARE(T::staticMetaObject.method(idx).revision(), 0); idx = T::staticMetaObject.indexOfMethod("method2()"); - QCOMPARE(T::staticMetaObject.method(idx).revision(), 4); + QCOMPARE(T::staticMetaObject.method(idx).revision(), + QTypeRevision::fromMinorVersion(4).toEncodedVersion()); + idx = T::staticMetaObject.indexOfMethod("method60()"); + QCOMPARE(T::staticMetaObject.method(idx).revision(), + QTypeRevision::fromVersion(6, 0).toEncodedVersion()); idx = T::staticMetaObject.indexOfSlot("slot1()"); QCOMPARE(T::staticMetaObject.method(idx).revision(), 0); idx = T::staticMetaObject.indexOfSlot("slot2()"); - QCOMPARE(T::staticMetaObject.method(idx).revision(), 3); + QCOMPARE(T::staticMetaObject.method(idx).revision(), + QTypeRevision::fromMinorVersion(3).toEncodedVersion()); + idx = T::staticMetaObject.indexOfSlot("slot61()"); + QCOMPARE(T::staticMetaObject.method(idx).revision(), + QTypeRevision::fromVersion(6, 1).toEncodedVersion()); idx = T::staticMetaObject.indexOfSlot("slot3()"); - QCOMPARE(T::staticMetaObject.method(idx).revision(), 6); + QCOMPARE(T::staticMetaObject.method(idx).revision(), + QTypeRevision::fromMinorVersion(6).toEncodedVersion()); idx = T::staticMetaObject.indexOfSlot("slot4()"); - QCOMPARE(T::staticMetaObject.method(idx).revision(), 6); + QCOMPARE(T::staticMetaObject.method(idx).revision(), + QTypeRevision::fromMinorVersion(6).toEncodedVersion()); + idx = T::staticMetaObject.indexOfSlot("slot512()"); + QCOMPARE(T::staticMetaObject.method(idx).revision(), + QTypeRevision::fromVersion(5, 12).toEncodedVersion()); idx = T::staticMetaObject.indexOfSignal("signal1()"); QCOMPARE(T::staticMetaObject.method(idx).revision(), 0); idx = T::staticMetaObject.indexOfSignal("signal2()"); - QCOMPARE(T::staticMetaObject.method(idx).revision(), 5); + QCOMPARE(T::staticMetaObject.method(idx).revision(), + QTypeRevision::fromMinorVersion(5).toEncodedVersion()); + idx = T::staticMetaObject.indexOfSignal("signal62()"); + QCOMPARE(T::staticMetaObject.method(idx).revision(), + QTypeRevision::fromVersion(6, 2).toEncodedVersion()); idx = T::staticMetaObject.indexOfSignal("signal3()"); - QCOMPARE(T::staticMetaObject.method(idx).revision(), 7); + QCOMPARE(T::staticMetaObject.method(idx).revision(), + QTypeRevision::fromMinorVersion(7).toEncodedVersion()); idx = T::staticMetaObject.indexOfSignal("signal4()"); - QCOMPARE(T::staticMetaObject.method(idx).revision(), 7); + QCOMPARE(T::staticMetaObject.method(idx).revision(), + QTypeRevision::fromMinorVersion(7).toEncodedVersion()); + idx = T::staticMetaObject.indexOfSignal("signal515()"); + QCOMPARE(T::staticMetaObject.method(idx).revision(), + QTypeRevision::fromVersion(5, 15).toEncodedVersion()); idx = T::staticMetaObject.indexOfEnumerator("TestEnum"); QCOMPARE(T::staticMetaObject.enumerator(idx).keyCount(), 2); -- cgit v1.2.3 From dfaa61482c483117b2d9728c0e9487fc2f8196c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Fri, 7 Feb 2020 15:14:08 +0100 Subject: Blacklist tst_QGuiApplication::quitOnLastWindowClosedMulti on macOS in CI Change-Id: I55cb9a6b3aebac68fb1b20127ba7aa501b4a3f2b Reviewed-by: Edward Welbourne Reviewed-by: Simon Hausmann --- tests/auto/gui/kernel/qguiapplication/BLACKLIST | 3 +++ 1 file changed, 3 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/gui/kernel/qguiapplication/BLACKLIST b/tests/auto/gui/kernel/qguiapplication/BLACKLIST index e6ffe78ae3..58ca7bf782 100644 --- a/tests/auto/gui/kernel/qguiapplication/BLACKLIST +++ b/tests/auto/gui/kernel/qguiapplication/BLACKLIST @@ -1,3 +1,6 @@ [focusObject] ubuntu-16.04 opensuse-42.3 + +[quitOnLastWindowClosedMulti] +macos ci -- cgit v1.2.3 From f19fbbdb2f5a3dbf3bac7cdbb4f7e8efe34f1e0d Mon Sep 17 00:00:00 2001 From: Vitaly Fanaskov Date: Thu, 12 Dec 2019 11:28:52 +0100 Subject: QVector: implement methods for adding new elements constructed in place Fixes: QTBUG-80293 Change-Id: I687dc05a9ad2bad7bab3dc2b1173edf75550d57e Reviewed-by: Qt CI Bot Reviewed-by: Lars Knoll --- tests/auto/corelib/tools/qvector/tst_qvector.cpp | 181 +++++++++++++++++++++++ 1 file changed, 181 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/corelib/tools/qvector/tst_qvector.cpp b/tests/auto/corelib/tools/qvector/tst_qvector.cpp index 7a69e844d4..6ae312fb8d 100644 --- a/tests/auto/corelib/tools/qvector/tst_qvector.cpp +++ b/tests/auto/corelib/tools/qvector/tst_qvector.cpp @@ -324,6 +324,18 @@ private slots: void swapItemsAt() const; + void emplaceInt(); + void emplaceCustom(); + void emplaceMovable(); + void emplaceConsistentWithStdVectorInt(); + void emplaceConsistentWithStdVectorCustom(); + void emplaceConsistentWithStdVectorMovable(); + void emplaceReturnsIterator(); + void emplaceBack(); + void emplaceBackReturnsRef(); + void emplaceWithElementFromTheSameContainer(); + void emplaceWithElementFromTheSameContainer_data(); + private: template void copyConstructor() const; template void add() const; @@ -349,6 +361,8 @@ private: template void initializeList(); template void detach() const; template void detachThreadSafety() const; + template void emplaceImpl() const; + template void emplaceConsistentWithStdVectorImpl() const; }; @@ -2645,5 +2659,172 @@ void tst_QVector::swapItemsAt() const QCOMPARE(copy.at(2), 2); } +void tst_QVector::emplaceInt() +{ + emplaceImpl(); +} + +void tst_QVector::emplaceCustom() +{ + emplaceImpl(); +} + +void tst_QVector::emplaceMovable() +{ + emplaceImpl(); +} + +void tst_QVector::emplaceConsistentWithStdVectorInt() +{ + emplaceConsistentWithStdVectorImpl(); +} + +void tst_QVector::emplaceConsistentWithStdVectorCustom() +{ + emplaceConsistentWithStdVectorImpl(); +} + +void tst_QVector::emplaceConsistentWithStdVectorMovable() +{ + emplaceConsistentWithStdVectorImpl(); +} + +void tst_QVector::emplaceReturnsIterator() +{ + QVector vec; + + vec.emplace(0, 'k')->i = 'p'; + + QCOMPARE(vec[0].i, 'p'); +} + +void tst_QVector::emplaceBack() +{ + QScopedValueRollback rollback(Movable::counter, 0); + + QVector vec; + + vec.emplaceBack('k'); + + QCOMPARE(Movable::counter, 1); +} + +void tst_QVector::emplaceBackReturnsRef() +{ + QVector vec; + + vec.emplaceBack('k').i = 'p'; + + QCOMPARE(vec.at(0).i, 'p'); +} + +void tst_QVector::emplaceWithElementFromTheSameContainer() +{ + QFETCH(int, elementPos); + QFETCH(int, insertPos); + QFETCH(bool, doCopy); + + QVector vec {"a", "b", "c", "d", "e"}; + const QString e = vec[elementPos]; + + if (doCopy) + vec.emplace(insertPos, vec[elementPos]); + else + vec.emplace(insertPos, std::move(vec[elementPos])); + + QCOMPARE(vec[insertPos], e); +} + +void tst_QVector::emplaceWithElementFromTheSameContainer_data() +{ + QTest::addColumn("elementPos"); + QTest::addColumn("insertPos"); + QTest::addColumn("doCopy"); + + for (int i = 0; i < 2; ++i) { + const bool doCopy = i == 0; + const char *opName = doCopy ? "copy" : "move"; + + QTest::addRow("%s: begin -> end" , opName) << 0 << 5 << doCopy; + QTest::addRow("%s: begin -> middle", opName) << 0 << 2 << doCopy; + QTest::addRow("%s: middle -> begin" , opName) << 2 << 0 << doCopy; + QTest::addRow("%s: middle -> end" , opName) << 2 << 5 << doCopy; + QTest::addRow("%s: end -> middle", opName) << 4 << 2 << doCopy; + QTest::addRow("%s: end -> begin" , opName) << 4 << 0 << doCopy; + } +} + +template +void tst_QVector::emplaceImpl() const +{ + QVector vec {'a', 'b', 'c', 'd'}; + + vec.emplace(2, 'k'); + + QCOMPARE(vec[2], T('k')); +} + +template +static void vecEq(const QVector &qVec, const std::vector &stdVec) +{ + QCOMPARE(std::size_t(qVec.size()), stdVec.size()); + QVERIFY(std::equal(qVec.begin(), qVec.end(), stdVec.begin(), stdVec.end())); +} + +template +static void squeezeVec(QVector &qVec, std::vector &stdVec) +{ + qVec.squeeze(); + stdVec.shrink_to_fit(); +} + +template +void tst_QVector::emplaceConsistentWithStdVectorImpl() const +{ + QVector qVec {'a', 'b', 'c', 'd', 'e'}; + std::vector stdVec {'a', 'b', 'c', 'd', 'e'}; + vecEq(qVec, stdVec); + + qVec.emplaceBack('f'); + stdVec.emplace_back('f'); + vecEq(qVec, stdVec); + + qVec.emplace(3, 'g'); + stdVec.emplace(stdVec.begin() + 3, 'g'); + vecEq(qVec, stdVec); + + qVec.emplaceBack(std::move(qVec[0])); + stdVec.emplace_back(std::move(stdVec[0])); + vecEq(qVec, stdVec); + + squeezeVec(qVec, stdVec); + + qVec.emplaceBack(std::move(qVec[1])); + stdVec.emplace_back(std::move(stdVec[1])); + vecEq(qVec, stdVec); + + squeezeVec(qVec, stdVec); + + qVec.emplace(3, std::move(qVec[5])); + stdVec.emplace(stdVec.begin() + 3, std::move(stdVec[5])); + vecEq(qVec, stdVec); + + qVec.emplaceBack(qVec[3]); + stdVec.emplace_back(stdVec[3]); + vecEq(qVec, stdVec); + + squeezeVec(qVec, stdVec); + + qVec.emplaceBack(qVec[4]); + stdVec.emplace_back(stdVec[4]); + vecEq(qVec, stdVec); + + squeezeVec(qVec, stdVec); + + qVec.emplace(5, qVec[7]); + stdVec.emplace(stdVec.begin() + 5, stdVec[7]); + vecEq(qVec, stdVec); +} + QTEST_MAIN(tst_QVector) #include "tst_qvector.moc" -- cgit v1.2.3 From 9cc8949cc63e47da3db333a699ff55ffa811783b Mon Sep 17 00:00:00 2001 From: Vitaly Fanaskov Date: Tue, 4 Feb 2020 15:31:25 +0100 Subject: QComboBox: remove deprecated signals The following signals have been removed: - void activated(const QString &); - void highlighted(const QString &); Task-number: QTBUG-81845 Change-Id: I61b552d9258987d4252202953aaf4909f9bd718e Reviewed-by: Qt CI Bot Reviewed-by: Christian Ehrlicher --- tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp | 4 ++-- tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp index 89c4a74739..fe3e3c7f72 100644 --- a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp +++ b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp @@ -1807,7 +1807,7 @@ void tst_QCompleter::QTBUG_52028_tabAutoCompletes() QApplication::setActiveWindow(&w); QVERIFY(QTest::qWaitForWindowActive(&w)); - QSignalSpy activatedSpy(&cbox, QOverload::of(&QComboBox::activated)); + QSignalSpy activatedSpy(&cbox, &QComboBox::activated); // Tab key will complete but not activate cbox.lineEdit()->clear(); @@ -1851,7 +1851,7 @@ void tst_QCompleter::QTBUG_51889_activatedSentTwice() QApplication::setActiveWindow(&w); QVERIFY(QTest::qWaitForWindowActive(&w)); - QSignalSpy activatedSpy(&cbox, QOverload::of(&QComboBox::activated)); + QSignalSpy activatedSpy(&cbox, &QComboBox::activated); // Navigate + enter activates only once (first item) cbox.lineEdit()->clear(); diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp index 3878e7ccb2..1f301fd60f 100644 --- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp @@ -2484,7 +2484,7 @@ void tst_QComboBox::task247863_keyBoardSelection() QApplication::setActiveWindow(&combo); QTRY_COMPARE(QApplication::activeWindow(), static_cast(&combo)); - QSignalSpy spy(&combo, SIGNAL(activated(QString))); + QSignalSpy spy(&combo, &QComboBox::activated); qApp->setEffectEnabled(Qt::UI_AnimateCombo, false); QTest::keyClick(&combo, Qt::Key_Space); qApp->setEffectEnabled(Qt::UI_AnimateCombo, true); -- cgit v1.2.3 From e59094cb86b01396d7cfc2b337c58cfbef5b2455 Mon Sep 17 00:00:00 2001 From: Vitaly Fanaskov Date: Fri, 7 Feb 2020 09:36:54 +0100 Subject: QSpinBox: remove deprecated signal valueChanged(const QString &) Task-number: QTBUG-81845 Change-Id: I91148cac553f63b44968337ccc121e7376ee4465 Reviewed-by: Christian Ehrlicher --- tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp | 4 ++-- tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp b/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp index c6de750482..cec2da1d57 100644 --- a/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp +++ b/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp @@ -419,7 +419,7 @@ void tst_QDoubleSpinBox::setTracking() spin.setDecimals(decimals); spin.show(); - connect(&spin, SIGNAL(valueChanged(QString)), this, SLOT(valueChangedHelper(QString))); + connect(&spin, SIGNAL(textChanged(QString)), this, SLOT(valueChangedHelper(QString))); keys.simulate(&spin); QCOMPARE(actualTexts, texts); @@ -1774,7 +1774,7 @@ void tst_QDoubleSpinBox::stepModifierPressAndHold() stepModifierStyle->stepModifier = static_cast(stepModifier); spin.setStyle(stepModifierStyle.data()); - QSignalSpy spy(&spin, QOverload::of(&DoubleSpinBox::valueChanged)); + QSignalSpy spy(&spin, &DoubleSpinBox::valueChanged); spin.show(); QVERIFY(QTest::qWaitForWindowExposed(&spin)); diff --git a/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp b/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp index 5b49e3484c..a8b47ffc46 100644 --- a/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp +++ b/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp @@ -1830,9 +1830,9 @@ void tst_QSpinBox::stepModifierPressAndHold() stepModifierStyle->stepModifier = static_cast(stepModifier); spin.setStyle(stepModifierStyle.data()); - QSignalSpy spy(&spin, QOverload::of(&SpinBox::valueChanged)); + QSignalSpy spy(&spin, &SpinBox::valueChanged); // TODO: remove debug output when QTBUG-69492 is fixed - connect(&spin, QOverload::of(&SpinBox::valueChanged), [=]() { + connect(&spin, &SpinBox::valueChanged, [=]() { qDebug() << QTime::currentTime() << "valueChanged emitted"; }); -- cgit v1.2.3