feat add Promise
This commit is contained in:
21
src/futures/promise_test.cc
Normal file
21
src/futures/promise_test.cc
Normal file
@@ -0,0 +1,21 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <sled/futures/promise.h>
|
||||
|
||||
TEST(Promise, Basic)
|
||||
{
|
||||
auto p = sled::Promise<int>();
|
||||
auto v = p.Then([](int v) {
|
||||
EXPECT_EQ(v, 1);
|
||||
return v + 10;
|
||||
})
|
||||
.Tap([](int v) {
|
||||
EXPECT_EQ(v, 11);
|
||||
// no effect
|
||||
return v + 1;
|
||||
})
|
||||
.Then([](int v) {
|
||||
EXPECT_EQ(v, 11);
|
||||
return v + 10;
|
||||
});
|
||||
p.Resolve(1);
|
||||
}
|
Reference in New Issue
Block a user