From 54d88f16a36e73f8cb6356095b5e8a7d6b20e496 Mon Sep 17 00:00:00 2001 From: Simon Brunel Date: Tue, 22 May 2018 09:52:05 +0200 Subject: [PATCH] Reorganize helpers unit tests --- .../{qpromise => helpers}/all/all.pro | 2 +- tests/auto/qtpromise/helpers/all/tst_all.cpp | 221 ++++++++++++++++ tests/auto/qtpromise/helpers/helpers.pro | 9 +- .../{qpromise => helpers}/reject/reject.pro | 2 +- .../reject/tst_reject.cpp | 10 +- .../{qpromise => helpers}/resolve/resolve.pro | 2 +- .../resolve/tst_resolve.cpp | 51 +++- tests/auto/qtpromise/helpers/tst_helpers.cpp | 244 ------------------ tests/auto/qtpromise/qpromise/all/tst_all.cpp | 103 -------- tests/auto/qtpromise/qpromise/qpromise.pro | 3 - 10 files changed, 279 insertions(+), 368 deletions(-) rename tests/auto/qtpromise/{qpromise => helpers}/all/all.pro (69%) create mode 100644 tests/auto/qtpromise/helpers/all/tst_all.cpp rename tests/auto/qtpromise/{qpromise => helpers}/reject/reject.pro (68%) rename tests/auto/qtpromise/{qpromise => helpers}/reject/tst_reject.cpp (85%) rename tests/auto/qtpromise/{qpromise => helpers}/resolve/resolve.pro (67%) rename tests/auto/qtpromise/{qpromise => helpers}/resolve/tst_resolve.cpp (50%) delete mode 100644 tests/auto/qtpromise/helpers/tst_helpers.cpp delete mode 100644 tests/auto/qtpromise/qpromise/all/tst_all.cpp diff --git a/tests/auto/qtpromise/qpromise/all/all.pro b/tests/auto/qtpromise/helpers/all/all.pro similarity index 69% rename from tests/auto/qtpromise/qpromise/all/all.pro rename to tests/auto/qtpromise/helpers/all/all.pro index 80abf7d..f098dfe 100644 --- a/tests/auto/qtpromise/qpromise/all/all.pro +++ b/tests/auto/qtpromise/helpers/all/all.pro @@ -1,4 +1,4 @@ -TARGET = tst_qpromise_all +TARGET = tst_helpers_all SOURCES += $$PWD/tst_all.cpp include(../../qtpromise.pri) diff --git a/tests/auto/qtpromise/helpers/all/tst_all.cpp b/tests/auto/qtpromise/helpers/all/tst_all.cpp new file mode 100644 index 0000000..a0da309 --- /dev/null +++ b/tests/auto/qtpromise/helpers/all/tst_all.cpp @@ -0,0 +1,221 @@ +// Tests +#include "../../shared/utils.h" + +// QtPromise +#include + +// Qt +#include + +using namespace QtPromise; + +class tst_helpers_all : public QObject +{ + Q_OBJECT + +private Q_SLOTS: + void emptySequence(); + void emptySequence_void(); + void allPromisesSucceed(); + void allPromisesSucceed_void(); + void atLeastOnePromiseReject(); + void atLeastOnePromiseReject_void(); + void preserveOrder(); + void sequenceTypes(); + void sequenceTypes_void(); +}; + +QTEST_MAIN(tst_helpers_all) +#include "tst_all.moc" + +namespace { + +template +struct SequenceTester +{ + Q_STATIC_ASSERT((std::is_same>::value)); + + static void exec() + { + Sequence promises{ + QtPromise::qPromise(42), + QtPromise::qPromise(43), + QtPromise::qPromise(44) + }; + + promises.push_back(QtPromise::qPromise(45)); + promises.insert(++promises.begin(), QtPromise::qPromise(46)); + promises.pop_back(); + + auto p = QtPromise::qPromiseAll(promises); + + Q_STATIC_ASSERT((std::is_same>>::value)); + QCOMPARE(p.isPending(), true); + QCOMPARE(waitForValue(p, QVector()), QVector({42, 46, 43, 44})); + } +}; + +template