feat add Promise

This commit is contained in:
tqcq
2024-03-23 18:18:15 +08:00
parent 95845b14dc
commit c0a2b73d0d
5 changed files with 1411 additions and 9 deletions

View 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);
}