summaryrefslogtreecommitdiff
path: root/tests/auto/algorithm/tst_algorithm.cpp
diff options
context:
space:
mode:
authorTobias Hunger <tobias.hunger@qt.io>2017-12-01 11:01:19 +0100
committerTobias Hunger <tobias.hunger@qt.io>2017-12-01 13:16:37 +0000
commit9b832f670d06e47940851f622a117da826ce75a6 (patch)
tree22d142c9983c573f0684be8958eb8d4b80394a27 /tests/auto/algorithm/tst_algorithm.cpp
parent8cd2c234db8f0a0576c9e1653a56be2c4e79403c (diff)
downloadqt-creator-9b832f670d06e47940851f622a117da826ce75a6.tar.gz
Utils: Implement more Utils::anyOf variations
Change-Id: I0cba5b58dde6003f5c5cb399142f985cbe83f0a7 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Diffstat (limited to 'tests/auto/algorithm/tst_algorithm.cpp')
-rw-r--r--tests/auto/algorithm/tst_algorithm.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/auto/algorithm/tst_algorithm.cpp b/tests/auto/algorithm/tst_algorithm.cpp
index 97581bb3d4..d1f76d16d8 100644
--- a/tests/auto/algorithm/tst_algorithm.cpp
+++ b/tests/auto/algorithm/tst_algorithm.cpp
@@ -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