Refactor async (#71)

This commit is contained in:
ykiko
2025-02-13 23:20:03 +08:00
committed by GitHub
parent e0bb2c453f
commit a9f7223d09
25 changed files with 1006 additions and 512 deletions

24
unittests/Async/Sleep.cpp Normal file
View File

@@ -0,0 +1,24 @@
#include "Test/Test.h"
#include "Async/Async.h"
namespace clice::testing {
namespace {
TEST(Async, Sleep) {
int x = 1;
auto task_gen = [&]() -> async::Task<> {
x = 2;
co_await async::sleep(100);
x = 3;
};
auto task = task_gen();
async::run(task);
EXPECT_EQ(x, 3);
}
} // namespace
} // namespace clice::testing