@@ -35,8 +35,9 @@ TEST(coroutine_base, get_init_msec) {
35
35
36
36
TEST (coroutine_base, yield_resume) {
37
37
Coroutine::set_on_yield ([](void *arg) {
38
- long task = *(long *) Coroutine::get_current_task ();
39
- ASSERT_EQ (task, Coroutine::get_current_cid ());
38
+ auto task = static_cast <long *>(Coroutine::get_current_task ());
39
+ ASSERT_NE (task, nullptr );
40
+ ASSERT_EQ (*task, Coroutine::get_current_cid ());
40
41
});
41
42
42
43
Coroutine::set_on_resume ([](void *arg) {
@@ -45,18 +46,19 @@ TEST(coroutine_base, yield_resume) {
45
46
});
46
47
47
48
Coroutine::set_on_close ([](void *arg) {
48
- long task = *(long *) Coroutine::get_current_task ();
49
- ASSERT_EQ (task, Coroutine::get_current_cid ());
49
+ auto task = static_cast <long *>(Coroutine::get_current_task ());
50
+ ASSERT_NE (task, nullptr );
51
+ ASSERT_EQ (*task, Coroutine::get_current_cid ());
50
52
});
51
53
52
- long _cid;
54
+ long _cid, _cid2 ;
53
55
long cid = Coroutine::create (
54
- [](void *arg) {
55
- long cid = Coroutine::get_current_cid ();
56
- Coroutine *co = Coroutine::get_by_cid (cid );
57
- co->set_task (( void *) &cid );
56
+ [&_cid2 ](void *arg) {
57
+ _cid2 = Coroutine::get_current_cid ();
58
+ Coroutine *co = Coroutine::get_by_cid (_cid2 );
59
+ co->set_task (&_cid2 );
58
60
co->yield ();
59
- *( long *) arg = Coroutine::get_current_cid ();
61
+ *static_cast < long *>( arg) = Coroutine::get_current_cid ();
60
62
},
61
63
&_cid);
62
64
0 commit comments