forked from qt-creator/qt-creator
Utils: Implement more Utils::anyOf variations
Change-Id: I0cba5b58dde6003f5c5cb399142f985cbe83f0a7 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -38,6 +38,7 @@ class tst_Algorithm : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
void anyOf();
|
||||
void transform();
|
||||
void sort();
|
||||
void contains();
|
||||
@@ -63,6 +64,29 @@ struct Struct
|
||||
};
|
||||
}
|
||||
|
||||
void tst_Algorithm::anyOf()
|
||||
{
|
||||
{
|
||||
const QList<QString> strings({"1", "3", "132"});
|
||||
QVERIFY(Utils::anyOf(strings, [](const QString &s) { return s == "132"; }));
|
||||
QVERIFY(!Utils::anyOf(strings, [](const QString &s) { return s == "1324"; }));
|
||||
}
|
||||
{
|
||||
const QList<Struct> list({2, 4, 6, 8});
|
||||
QVERIFY(Utils::anyOf(list, &Struct::isEven));
|
||||
QVERIFY(!Utils::anyOf(list, &Struct::isOdd));
|
||||
}
|
||||
{
|
||||
const QList<Struct> list({0, 0, 0, 0, 1, 0, 0});
|
||||
QVERIFY(Utils::anyOf(list, &Struct::member));
|
||||
}
|
||||
{
|
||||
const QList<Struct> list({0, 0, 0, 0, 0, 0, 0});
|
||||
QVERIFY(!Utils::anyOf(list, &Struct::member));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void tst_Algorithm::transform()
|
||||
{
|
||||
// same container type
|
||||
|
Reference in New Issue
Block a user