-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable QPromise<T>::resolve() by reference
- Loading branch information
1 parent
18739bd
commit 4af2740
Showing
6 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ SUBDIRS += \ | |
fail \ | ||
finally \ | ||
operators \ | ||
resolve \ | ||
tap \ | ||
then \ | ||
timeout |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
TARGET = tst_qpromise_resolve | ||
SOURCES += $$PWD/tst_resolve.cpp | ||
|
||
include(../../qtpromise.pri) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Tests | ||
#include "../../shared/utils.h" | ||
|
||
// QtPromise | ||
#include <QtPromise> | ||
|
||
// Qt | ||
#include <QtTest> | ||
|
||
using namespace QtPromise; | ||
|
||
class tst_qpromise_resolve : public QObject | ||
{ | ||
Q_OBJECT | ||
|
||
private Q_SLOTS: | ||
void value(); | ||
void empty_void(); | ||
}; | ||
|
||
QTEST_MAIN(tst_qpromise_resolve) | ||
#include "tst_resolve.moc" | ||
|
||
void tst_qpromise_resolve::value() | ||
{ | ||
const int value = 42; | ||
auto p0 = QPromise<int>::resolve(value); | ||
auto p1 = QPromise<int>::resolve(43); | ||
|
||
QCOMPARE(p0.isFulfilled(), true); | ||
QCOMPARE(p1.isFulfilled(), true); | ||
QCOMPARE(waitForValue(p0, -1), 42); | ||
QCOMPARE(waitForValue(p1, -1), 43); | ||
} | ||
|
||
void tst_qpromise_resolve::empty_void() | ||
{ | ||
auto p = QPromise<void>::resolve(); | ||
|
||
QCOMPARE(p.isFulfilled(), true); | ||
} |