FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cppcode/test/TaskFlowTest/TaskFlowTest.cpp at master · junessi/cppcode · GitHub
junessi
/
cppcode
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
2
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
cppcode
/
test
/
TaskFlowTest
/
TaskFlowTest.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
60 lines (50 loc) · 1.23 KB
Breadcrumbs
cppcode
/
test
/
TaskFlowTest
/
TaskFlowTest.cpp
Copy path
File metadata and controls
60 lines (50 loc) · 1.23 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#
include
<
gtest/gtest.h
>
#
include
<
vector
>
#
include
<
thread
>
#
include
<
chrono
>
#
include
<
sstream
>
#
include
<
cppcode/taskflow/task.hpp
>
#
include
<
cppcode/taskflow/taskflow.hpp
>
TEST
(TaskFlowTest, test0)
{
using
cppcode::taskflow::Task;
using
cppcode::taskflow::TaskFlow;
using
cppcode::taskflow::TaskOperation;
std::ostringstream oss;
TaskFlow tf;
//
create task A
TaskOperation opA = [&oss]()
{
std::this_thread::sleep_for
(
std::chrono::milliseconds
(
500
));
oss <<
"
A
"
;
};
Task* A = tf.
add
(
"
A
"
, opA);
//
create task B
TaskOperation opB = [&oss](){ oss <<
"
B
"
;};
Task* B = tf.
add
(
"
B
"
, opB);
//
create task C
TaskOperation opC = [&oss]()
{
std::this_thread::sleep_for
(
std::chrono::milliseconds
(
500
));
oss <<
"
C
"
;
};
Task* C = tf.
add
(
"
C
"
, opC);
//
create task D
TaskOperation opD = [&oss](){ oss <<
"
D
"
;};
Task* D = tf.
add
(
"
D
"
, opD);
/*
*
* A --> B -
* \ \
* -> C ---> D
*
*/
A->
precede
(B);
A->
precede
(C);
B->
precede
(D);
C->
precede
(D);
tf.
run
();
EXPECT_EQ
(
"
ABCD
"
, oss.
str
());
}
int
main
(
int
argc,
char
**argv) {
::testing::InitGoogleTest
(&argc, argv);
return
RUN_ALL_TESTS
();
}
Back
|
FazBrowse Home
|
New Git URL