Skip to content

Commit

Permalink
QHash: test tryEmplace/insert/OrAssign doesn't require default
Browse files Browse the repository at this point in the history
... ctor

Change-Id: I117dc627226573d52cb107df48aad2f490cd429a
Reviewed-by: Thiago Macieira <[email protected]>
  • Loading branch information
Morten242 committed Dec 6, 2024
1 parent f81fd7b commit 9b6f33f
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/auto/corelib/tools/qhash/tst_qhash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1938,6 +1938,27 @@ void tst_QHash::dont_need_default_constructor()
QVERIFY(hash2.value(QString::number(i), Bar(-1)).j == 2 * i);
QVERIFY(hash2.size() == i + 1);
}

QHash<int, Bar> hash3;
for (int i = 0; i < 100; ++i) {
hash3.tryEmplace(i, Bar(2 * i));
QVERIFY(hash3.value(i, Bar(-1)).j == 2 * i);
QVERIFY(hash3.size() == i + 1);
}

QHash<int, Bar> hash4;
for (int i = 0; i < 100; ++i) {
hash4.tryInsert(i, Bar(2 * i));
QVERIFY(hash4.value(i, Bar(-1)).j == 2 * i);
QVERIFY(hash4.size() == i + 1);
}

QHash<int, Bar> hash5;
for (int i = 0; i < 100; ++i) {
hash5.insertOrAssign(i, Bar(2 * i));
QVERIFY(hash5.value(i, Bar(-1)).j == 2 * i);
QVERIFY(hash5.size() == i + 1);
}
}

void tst_QHash::qmultihash_specific()
Expand Down

0 comments on commit 9b6f33f

Please sign in to comment.