11 #if defined(LIBCOPP_MACRO_ENABLE_WIN_FIBER) && LIBCOPP_MACRO_ENABLE_WIN_FIBER
13 typedef copp::coroutine_fiber_context_default test_coroutine_context_fiber_test_type;
15 static int g_test_coroutine_fiber_status = 0;
17 class test_context_fiber_foo_runner {
19 test_context_fiber_foo_runner() : call_times(0) {}
21 int operator()(
void *) {
23 ++g_test_coroutine_fiber_status;
24 copp::this_fiber::get<test_coroutine_context_fiber_test_type>()->yield();
26 ++g_test_coroutine_fiber_status;
31 CASE_TEST(coroutine_fiber, context_base) {
32 g_test_coroutine_fiber_status = 0;
33 ++g_test_coroutine_fiber_status;
36 test_context_fiber_foo_runner runner;
38 copp::stack_context test_move_alloc;
40 test_coroutine_context_fiber_test_type::ptr_t co = test_coroutine_context_fiber_test_type::create(&runner);
41 runner.call_times = 0;
49 ++g_test_coroutine_fiber_status;
53 ++g_test_coroutine_fiber_status;
61 g_test_coroutine_fiber_status = 1;
62 copp::stack_context test_move_alloc;
64 test_coroutine_context_fiber_test_type::ptr_t co = test_coroutine_context_fiber_test_type::create(&runner);
65 runner.call_times = 0;
73 ++g_test_coroutine_fiber_status;
77 ++g_test_coroutine_fiber_status;
85 CASE_TEST(coroutine_fiber, shared_runner) {
86 g_test_coroutine_fiber_status = 0;
87 ++g_test_coroutine_fiber_status;
90 test_context_fiber_foo_runner runner;
91 runner.call_times = 0;
94 test_coroutine_context_fiber_test_type::ptr_t co[4];
95 for (
int i = 0; i < 4; ++i) {
96 co[i] = test_coroutine_context_fiber_test_type::create(&runner);
102 for (
int i = 0; i < 4; ++i) {
112 # if defined(LIBCOPP_MACRO_ENABLE_STD_EXCEPTION_PTR) && LIBCOPP_MACRO_ENABLE_STD_EXCEPTION_PTR
113 static int test_context_fiber_foo_runner_throw_exception(
void *) {
return static_cast<int>(std::string().at(1)); }
115 CASE_TEST(coroutine_fiber, coroutine_context_throw_exception) {
117 copp::stack_context test_move_alloc;
119 test_coroutine_context_fiber_test_type::ptr_t co =
120 test_coroutine_context_fiber_test_type::create(test_context_fiber_foo_runner_throw_exception);
127 }
catch (
const std::exception &e) {
128 CASE_MSG_INFO() <<
"Caught exception \"" << e.what() <<
"\"" << std::endl;
@ COPP_EC_NOT_READY
COPP_EC_NOT_READY.
@ COPP_EC_ALREADY_EXIST
COPP_EC_ALREADY_EXIST.
@ COPP_EC_NOT_RUNNING
COPP_EC_NOT_RUNNING.
#define CASE_EXPECT_EQ(l, r)
#define CASE_TEST(test_name, case_name)
#define CASE_EXPECT_TRUE(c)