QDuplicateTracker: test with std::string, too
std::string is a nice value_type for when you want to track short strings (because of its SSO). Check that it works, incl. in case the implementation falls back to QSet in the absence of std::pmr support in the stdlib. Pick-to: 6.6 6.5 Change-Id: I2406258355295c2b1300c4ae8001cead59bb27d6 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit fe8c8e0fceec09b6ac6f358d522aeae9a5550bd0) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
9039b0cd25
commit
3446ece056
@ -6,6 +6,8 @@
|
||||
#include <QtCore/private/qduplicatetracker_p.h>
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
class tst_QDuplicateTracker : public QObject
|
||||
@ -50,6 +52,27 @@ void tst_QDuplicateTracker::hasSeen()
|
||||
QVERIFY(!tracker.hasSeen(string3));
|
||||
QVERIFY(tracker.hasSeen(string3));
|
||||
}
|
||||
|
||||
{
|
||||
QDuplicateTracker<std::string, 2> tracker;
|
||||
std::string string1("string1");
|
||||
std::string string2("string2");
|
||||
std::string string2_2("string2");
|
||||
std::string string3("string3");
|
||||
|
||||
// Move when seen
|
||||
QVERIFY(!tracker.hasSeen(string1));
|
||||
QVERIFY(tracker.hasSeen(std::move(string1)));
|
||||
|
||||
// Move when unseen
|
||||
QVERIFY(!tracker.hasSeen(std::move(string2)));
|
||||
QVERIFY(tracker.hasSeen(string2_2));
|
||||
|
||||
// Past the prealloc amount
|
||||
QVERIFY(!tracker.hasSeen(string3));
|
||||
QVERIFY(tracker.hasSeen(string3));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void tst_QDuplicateTracker::clear()
|
||||
|
Loading…
x
Reference in New Issue
Block a user