summaryrefslogtreecommitdiff
path: root/tests/auto/algorithm/tst_algorithm.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/algorithm/tst_algorithm.cpp')
-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()