summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorOrgad Shaneh <orgad.shaneh@audiocodes.com>2017-03-09 22:11:11 +0200
committerOrgad Shaneh <orgads@gmail.com>2017-03-10 11:37:03 +0000
commit4136e36c6f93aa41f855646c6480baba7029a6f2 (patch)
tree23ac8af05ed1c9e9503bd050d0ebce3033fb0f59 /tests
parentbc562bbea91aded8cee188541413b4bb54ea12a2 (diff)
downloadqt-creator-4136e36c6f93aa41f855646c6480baba7029a6f2.tar.gz
Algorithm: Add a member variant for transform
Change-Id: I329ee764cc13dd8b794c6769a2baf2f41d6a9983 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/algorithm/tst_algorithm.cpp25
1 files changed, 15 insertions, 10 deletions
diff --git a/tests/auto/algorithm/tst_algorithm.cpp b/tests/auto/algorithm/tst_algorithm.cpp
index 614cf3fa12..47e05b4636 100644
--- a/tests/auto/algorithm/tst_algorithm.cpp
+++ b/tests/auto/algorithm/tst_algorithm.cpp
@@ -42,6 +42,16 @@ int stringToInt(const QString &s)
return s.toInt();
}
+namespace {
+struct Struct
+{
+ Struct(int m) : member(m) {}
+ bool operator==(const Struct &other) const { return member == other.member; }
+
+ int member;
+};
+}
+
void tst_Algorithm::transform()
{
// same container type
@@ -110,16 +120,11 @@ void tst_Algorithm::transform()
Utils::sort(i3);
QCOMPARE(i3, QList<int>({1, 1, 3}));
}
-}
-
-namespace {
-struct Struct
-{
- Struct(int m) : member(m) {}
- bool operator==(const Struct &other) const { return member == other.member; }
-
- int member;
-};
+ {
+ const QList<Struct> list({4, 3, 2, 1, 2});
+ const QList<int> trans = Utils::transform(list, &Struct::member);
+ QCOMPARE(trans, QList<int>({4, 3, 2, 1, 2}));
+ }
}
void tst_Algorithm::sort()