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