diff options
author | Olivier Goffart <olivier.goffart@nokia.com> | 2011-05-18 15:55:43 (GMT) |
---|---|---|
committer | Olivier Goffart <olivier.goffart@nokia.com> | 2011-05-19 13:09:32 (GMT) |
commit | 38d1b31006ecc83811bbb13e5a4182eac593a970 (patch) | |
tree | c455ef2c081457b5af17d6e494ef9b0745601691 /tests | |
parent | a09f5c425079405e72078813bdb7b103c29a5221 (diff) | |
download | Qt-38d1b31006ecc83811bbb13e5a4182eac593a970.zip Qt-38d1b31006ecc83811bbb13e5a4182eac593a970.tar.gz Qt-38d1b31006ecc83811bbb13e5a4182eac593a970.tar.bz2 |
Tests for QtConcurrent::map using lambdas
Also disable tests with std::vector in c++0x as they do not compile
Reviewed-by: Joao
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qtconcurrentmap/tst_qtconcurrentmap.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/auto/qtconcurrentmap/tst_qtconcurrentmap.cpp b/tests/auto/qtconcurrentmap/tst_qtconcurrentmap.cpp index 2f1adb4..8814cde 100644 --- a/tests/auto/qtconcurrentmap/tst_qtconcurrentmap.cpp +++ b/tests/auto/qtconcurrentmap/tst_qtconcurrentmap.cpp @@ -146,6 +146,15 @@ void tst_QtConcurrentMap::map() QCOMPARE(numberList, QList<Number>() << 2 << 4 << 6); QtConcurrent::map(numberList.begin(), numberList.end(), &Number::multiplyBy2).waitForFinished(); QCOMPARE(numberList, QList<Number>() << 4 << 8 << 12); + +#ifdef Q_COMPILER_LAMBDA + // lambda + QtConcurrent::map(list, [](int &x){x *= 2;}).waitForFinished(); + QCOMPARE(list, QList<int>() << 128 << 256 << 384); + QtConcurrent::map(list.begin(), list.end(), [](int &x){x *= 2;}).waitForFinished(); + QCOMPARE(list, QList<int>() << 256 << 512 << 768); +#endif + } // functors don't take arguments by reference, making these no-ops @@ -170,6 +179,14 @@ void tst_QtConcurrentMap::map() QCOMPARE(list, QList<int>() << 1 << 2 << 3); QtConcurrent::map(list.begin(), list.end(), multiplyBy2Immutable).waitForFinished(); QCOMPARE(list, QList<int>() << 1 << 2 << 3); + +#ifdef Q_COMPILER_LAMBDA + // lambda + QtConcurrent::map(list, [](int x){x *= 2;}).waitForFinished(); + QCOMPARE(list, QList<int>() << 1 << 2 << 3); + QtConcurrent::map(list.begin(), list.end(), [](int x){x *= 2;}).waitForFinished(); + QCOMPARE(list, QList<int>() << 1 << 2 << 3); +#endif } // Linked lists and forward iterators @@ -2303,6 +2320,10 @@ void tst_QtConcurrentMap::stlContainers() { #ifdef QT_NO_STL QSKIP("Qt compiled without STL support", SkipAll); +#elif defined(Q_COMPILER_RVALUE_REFS) + //mapped uses &Container::push_back, but in c++0x, std::vector has two overload of it + // meaning it is not possible to take the address of that function anymore. + QSKIP("mapped do not work with c++0x stl vector", SkipAll); #else std::vector<int> vector; vector.push_back(1); |