libcopp
2.3.1
Toggle main menu visibility
Main Page
Related Pages
Namespaces
Namespace List
Namespace Members
All
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
w
x
y
Functions
_
a
c
d
f
g
h
i
m
o
p
r
s
t
w
y
Variables
_
a
b
c
d
e
f
g
h
l
m
o
p
r
s
t
u
w
x
Typedefs
Enumerations
Enumerator
Data Structures
Data Structures
Data Structure Index
Class Hierarchy
Data Fields
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
x
y
~
Functions
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
x
y
~
Variables
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
Typedefs
_
a
b
c
d
e
f
h
i
j
l
m
n
o
p
r
s
t
u
v
w
Enumerations
Enumerator
e
l
s
u
Related Symbols
_
d
e
i
l
o
r
s
w
Files
File List
Globals
All
_
b
c
e
g
j
l
m
o
p
r
s
t
u
w
Functions
b
c
g
j
m
o
p
r
s
t
Variables
b
c
g
m
s
t
Typedefs
Enumerations
Enumerator
c
e
Macros
_
c
l
m
s
t
u
w
•
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
Loading...
Searching...
No Matches
test
case
coroutine_context_private_data_test.cpp
Go to the documentation of this file.
1
// Copyright 2023 owent
2
3
#include <
libcopp/coroutine/coroutine_context_container.h
>
4
5
#include <cstdio>
6
#include <cstring>
7
#include <iostream>
8
9
#include "
frame/test_macros.h
"
10
11
typedef
copp::coroutine_context_container<copp::allocator::default_statck_allocator>
12
test_context_private_data_context_type
;
13
14
static
int
g_test_coroutine_private_data_status
= 0;
15
16
class
test_context_private_data_foo_runner
{
17
public
:
18
int
operator()
(
void
*priv_data) {
19
++
g_test_coroutine_private_data_status
;
20
CASE_EXPECT_EQ
(
g_test_coroutine_private_data_status
, 2);
21
CASE_EXPECT_EQ
(&
g_test_coroutine_private_data_status
, priv_data);
22
23
copp::this_coroutine::get<test_context_private_data_context_type>()->resume();
24
++
g_test_coroutine_private_data_status
;
25
CASE_EXPECT_EQ
(
g_test_coroutine_private_data_status
, 3);
26
27
copp::this_coroutine::get<test_context_private_data_context_type>()->yield(&priv_data);
28
++
g_test_coroutine_private_data_status
;
29
30
CASE_EXPECT_EQ
(copp::this_coroutine::get<test_context_private_data_context_type>(), priv_data);
31
CASE_EXPECT_EQ
(
g_test_coroutine_private_data_status
, 5);
32
33
return
0;
34
}
18
int
operator()
(
void
*priv_data) {
…
}
35
};
16
class
test_context_private_data_foo_runner
{
…
};
36
37
CASE_TEST
(coroutine, context_private_data) {
38
g_test_coroutine_private_data_status
= 0;
39
40
++
g_test_coroutine_private_data_status
;
41
CASE_EXPECT_EQ
(
g_test_coroutine_private_data_status
, 1);
42
43
test_context_private_data_context_type::ptr_t co =
44
test_context_private_data_context_type::create(
test_context_private_data_foo_runner
());
45
co->start(&
g_test_coroutine_private_data_status
);
46
47
++
g_test_coroutine_private_data_status
;
48
CASE_EXPECT_EQ
(
g_test_coroutine_private_data_status
, 4);
49
co->resume(co.get());
50
51
++
g_test_coroutine_private_data_status
;
52
CASE_EXPECT_EQ
(
g_test_coroutine_private_data_status
, 6);
53
}
37
CASE_TEST
(coroutine, context_private_data) {
…
}
test_context_private_data_foo_runner
Definition
coroutine_context_private_data_test.cpp:16
test_context_private_data_foo_runner::operator()
int operator()(void *priv_data)
Definition
coroutine_context_private_data_test.cpp:18
coroutine_context_container.h
g_test_coroutine_private_data_status
static int g_test_coroutine_private_data_status
Definition
coroutine_context_private_data_test.cpp:14
test_context_private_data_context_type
copp::coroutine_context_container< copp::allocator::default_statck_allocator > test_context_private_data_context_type
Definition
coroutine_context_private_data_test.cpp:12
test_macros.h
CASE_EXPECT_EQ
#define CASE_EXPECT_EQ(l, r)
Definition
test_macros.h:99
CASE_TEST
#define CASE_TEST(test_name, case_name)
Definition
test_macros.h:47
Generated by
1.9.8