diff options
author | Christian Stenger <christian.stenger@qt.io> | 2017-11-30 09:18:29 +0100 |
---|---|---|
committer | Tobias Hunger <tobias.hunger@qt.io> | 2017-11-30 09:21:51 +0000 |
commit | e5fae9b91427ba7f6e5eb5eb5e8f961bffd493cd (patch) | |
tree | d4283437f27be721335e6c1e703b909d265b6fbe /tests/auto/algorithm/tst_algorithm.cpp | |
parent | 67767f9925d9c1b848a0250581f9af4b3539855c (diff) | |
download | qt-creator-e5fae9b91427ba7f6e5eb5eb5e8f961bffd493cd.tar.gz |
Tests: Fix compile on Windows and Linux
Template code inside utils/algorithm.h is not correctly instantiated when
respective containers that shall use these functions are included after
the algorithm file.
Additionally there had been issues using nullptr as comparison inside
QCOMPARE().
Change-Id: I2bd6baf3890090c5f5bbbd6229afb9aeeb7617ef
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
Diffstat (limited to 'tests/auto/algorithm/tst_algorithm.cpp')
-rw-r--r-- | tests/auto/algorithm/tst_algorithm.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/tests/auto/algorithm/tst_algorithm.cpp b/tests/auto/algorithm/tst_algorithm.cpp index f87cc83a96..97581bb3d4 100644 --- a/tests/auto/algorithm/tst_algorithm.cpp +++ b/tests/auto/algorithm/tst_algorithm.cpp @@ -23,14 +23,16 @@ ** ****************************************************************************/ -#include <utils/algorithm.h> - #include <QtTest> #include <array> #include <memory> #include <valarray> +// must get included after the containers above or gcc4.9 will have a problem using +// initializer_list related code on the templates inside algorithm.h +#include <utils/algorithm.h> + class tst_Algorithm : public QObject { Q_OBJECT @@ -222,14 +224,14 @@ void tst_Algorithm::findOrDefault() v2.emplace_back(std::make_unique<int>(3)); v2.emplace_back(std::make_unique<int>(4)); QCOMPARE(Utils::findOrDefault(v2, [](const std::unique_ptr<int> &ip) { return *ip == 2; }), v2.at(1).get()); - QCOMPARE(Utils::findOrDefault(v2, [](const std::unique_ptr<int> &ip) { return *ip == 5; }), nullptr); + QCOMPARE(Utils::findOrDefault(v2, [](const std::unique_ptr<int> &ip) { return *ip == 5; }), static_cast<int*>(0)); std::vector<std::unique_ptr<Struct>> v3; v3.emplace_back(std::make_unique<Struct>(1)); v3.emplace_back(std::make_unique<Struct>(3)); v3.emplace_back(std::make_unique<Struct>(5)); v3.emplace_back(std::make_unique<Struct>(7)); QCOMPARE(Utils::findOrDefault(v3, &Struct::isOdd), v3.at(0).get()); - QCOMPARE(Utils::findOrDefault(v3, &Struct::isEven), nullptr); + QCOMPARE(Utils::findOrDefault(v3, &Struct::isEven), static_cast<Struct*>(0)); } QTEST_MAIN(tst_Algorithm) |