6
6
#include < string>
7
7
8
8
namespace {
9
- auto actual = std::string{};
9
+ [[maybe_unused]] auto actual = std::string{};
10
10
11
- constexpr auto milestone0 = flow::milestone<" milestone0" >();
12
- constexpr auto milestone1 = flow::milestone<" milestone1" >();
11
+ [[maybe_unused]] constexpr auto milestone0 = flow::milestone<" milestone0" >();
12
+ [[maybe_unused]] constexpr auto milestone1 = flow::milestone<" milestone1" >();
13
13
14
- constexpr auto a = flow::action<" a" >([] { actual += " a" ; });
15
- constexpr auto b = flow::action<" b" >([] { actual += " b" ; });
16
- constexpr auto c = flow::action<" c" >([] { actual += " c" ; });
17
- constexpr auto d = flow::action<" d" >([] { actual += " d" ; });
14
+ [[maybe_unused]] constexpr auto a = flow::action<" a" >([] { actual += " a" ; });
15
+ [[maybe_unused]] constexpr auto b = flow::action<" b" >([] { actual += " b" ; });
16
+ [[maybe_unused]] constexpr auto c = flow::action<" c" >([] { actual += " c" ; });
17
+ [[maybe_unused]] constexpr auto d = flow::action<" d" >([] { actual += " d" ; });
18
18
19
19
using builder = flow::graph_builder<flow::impl>;
20
20
} // namespace
21
21
22
+ struct empty_flow {
23
+ constexpr static auto value = flow::graph<>{};
24
+ };
22
25
TEST_CASE (" build and run empty flow" , " [graph_builder]" ) {
23
- auto g = flow::graph<>{};
24
- auto const flow = builder::build (g);
25
- REQUIRE (flow.has_value ());
26
- flow.value ()();
26
+ constexpr auto f = builder::render<empty_flow>();
27
+ f ();
27
28
}
28
29
30
+ struct single_action {
31
+ constexpr static auto value = flow::graph<>{}.add(a);
32
+ };
29
33
TEST_CASE (" add single action" , " [graph_builder]" ) {
30
34
actual.clear ();
31
- auto g = flow::graph<>{}.add (a);
32
- auto const flow = builder::build (g);
33
- REQUIRE (flow.has_value ());
34
- flow.value ()();
35
+ constexpr auto f = builder::render<single_action>();
36
+ f ();
35
37
CHECK (actual == " a" );
36
38
}
37
39
40
+ struct two_milestone_linear_before {
41
+ constexpr static auto value = flow::graph<>{}.add(a >> milestone0);
42
+ };
38
43
TEST_CASE (" two milestone linear before dependency" , " [graph_builder]" ) {
39
44
actual.clear ();
40
- auto g = flow::graph<>{}.add (a >> milestone0);
41
- auto const flow = builder::build (g);
42
- REQUIRE (flow.has_value ());
43
- flow.value ()();
45
+ constexpr auto f = builder::render<two_milestone_linear_before>();
46
+ f ();
44
47
CHECK (actual == " a" );
45
48
}
46
49
50
+ struct actions_get_executed_once {
51
+ constexpr static auto value = flow::graph<>{}
52
+ .add(a >> milestone0)
53
+ .add(a >> milestone1)
54
+ .add(milestone0 >> milestone1);
55
+ };
47
56
TEST_CASE (" actions get executed once" , " [graph_builder]" ) {
48
57
actual.clear ();
49
- auto g = flow::graph<>{}
50
- .add (a >> milestone0)
51
- .add (a >> milestone1)
52
- .add (milestone0 >> milestone1);
53
- auto const flow = builder::build (g);
54
- flow.value ()();
58
+ constexpr auto f = builder::render<actions_get_executed_once>();
59
+ f ();
55
60
CHECK (actual == " a" );
56
61
}
57
62
63
+ struct two_milestone_linear_after_dependency {
64
+ constexpr static auto value = flow::graph<>{}
65
+ .add(a >> milestone0)
66
+ .add(milestone0 >> milestone1)
67
+ .add(milestone0 >> b >> milestone1);
68
+ };
58
69
TEST_CASE (" two milestone linear after dependency" , " [graph_builder]" ) {
59
70
actual.clear ();
60
- auto g = flow::graph<>{}
61
- .add (a >> milestone0)
62
- .add (milestone0 >> milestone1)
63
- .add (milestone0 >> b >> milestone1);
64
- auto const flow = builder::build (g);
65
- flow.value ()();
71
+ constexpr auto f = builder::render<two_milestone_linear_after_dependency>();
72
+ f ();
66
73
CHECK (actual == " ab" );
67
74
}
68
75
76
+ struct three_milestone_linear_before_and_after_dependency {
77
+ constexpr static auto value = flow::graph<>{}.add(a >> b >> c);
78
+ };
69
79
TEST_CASE (" three milestone linear before and after dependency" ,
70
80
" [graph_builder]" ) {
71
81
actual.clear ();
72
- auto g = flow::graph<>{}. add (a >> b >> c);
73
- auto const flow = builder::build (g );
74
- flow. value () ();
82
+ constexpr auto f =
83
+ builder::render<three_milestone_linear_before_and_after_dependency>( );
84
+ f ();
75
85
CHECK (actual == " abc" );
76
86
}
77
87
88
+ struct just_two_actions_in_order {
89
+ constexpr static auto value = flow::graph<>{}.add(a >> b);
90
+ };
78
91
TEST_CASE (" just two actions in order" , " [graph_builder]" ) {
79
92
actual.clear ();
80
- auto g = flow::graph<>{}.add (a >> b);
81
- auto const flow = builder::build (g);
82
- flow.value ()();
93
+ constexpr auto f = builder::render<just_two_actions_in_order>();
94
+ f ();
83
95
CHECK (actual == " ab" );
84
96
}
85
97
98
+ struct insert_action_between_two_actions {
99
+ constexpr static auto value = flow::graph<>{}.add(a >> c).add(a >> b >> c);
100
+ };
86
101
TEST_CASE (" insert action between two actions" , " [graph_builder]" ) {
87
102
actual.clear ();
88
- auto g = flow::graph<>{}.add (a >> c).add (a >> b >> c);
89
- auto const flow = builder::build (g);
90
- flow.value ()();
103
+ constexpr auto f = builder::render<insert_action_between_two_actions>();
104
+ f ();
91
105
CHECK (actual == " abc" );
92
106
}
93
107
108
+ struct add_single_parallel_2 {
109
+ constexpr static auto value = flow::graph<>{}.add(a && b);
110
+ };
94
111
TEST_CASE (" add single parallel 2" , " [graph_builder]" ) {
95
112
actual.clear ();
96
- auto g = flow::graph<>{}.add (a && b);
97
- auto const flow = builder::build (g);
98
- flow.value ()();
113
+ constexpr auto f = builder::render<add_single_parallel_2>();
114
+ f ();
99
115
100
116
CHECK (actual.find (' a' ) != std::string::npos);
101
117
CHECK (actual.find (' b' ) != std::string::npos);
102
118
CHECK (actual.size () == 2 );
103
119
}
104
120
121
+ struct add_single_parallel_3 {
122
+ constexpr static auto value = flow::graph<>{}.add(a && b && c);
123
+ };
105
124
TEST_CASE (" add single parallel 3" , " [graph_builder]" ) {
106
125
actual.clear ();
107
- auto g = flow::graph<>{}.add (a && b && c);
108
- auto const flow = builder::build (g);
109
- flow.value ()();
126
+ constexpr auto f = builder::render<add_single_parallel_3>();
127
+ f ();
110
128
111
129
CHECK (actual.find (' a' ) != std::string::npos);
112
130
CHECK (actual.find (' b' ) != std::string::npos);
113
131
CHECK (actual.find (' c' ) != std::string::npos);
114
132
CHECK (actual.size () == 3 );
115
133
}
116
134
135
+ struct add_single_parallel_3_with_later_dependency_1 {
136
+ constexpr static auto value = flow::graph<>{}.add(a && b && c).add(c >> a);
137
+ };
117
138
TEST_CASE (" add single parallel 3 with later dependency 1" , " [graph_builder]" ) {
118
139
actual.clear ();
119
- auto g = flow::graph<>{}. add (a && b && c). add (c >> a);
120
- auto const flow = builder::build (g );
121
- flow. value () ();
140
+ constexpr auto f =
141
+ builder::render<add_single_parallel_3_with_later_dependency_1>( );
142
+ f ();
122
143
123
144
CHECK (actual.find (' a' ) != std::string::npos);
124
145
CHECK (actual.find (' b' ) != std::string::npos);
@@ -127,11 +148,14 @@ TEST_CASE("add single parallel 3 with later dependency 1", "[graph_builder]") {
127
148
CHECK (actual.size () == 3 );
128
149
}
129
150
151
+ struct add_single_parallel_3_with_later_dependency_2 {
152
+ constexpr static auto value = flow::graph<>{}.add(a && b && c).add(a >> c);
153
+ };
130
154
TEST_CASE (" add single parallel 3 with later dependency 2" , " [graph_builder]" ) {
131
155
actual.clear ();
132
- auto g = flow::graph<>{}. add (a && b && c). add (a >> c);
133
- auto const flow = builder::build (g );
134
- flow. value () ();
156
+ constexpr auto f =
157
+ builder::render<add_single_parallel_3_with_later_dependency_2>( );
158
+ f ();
135
159
136
160
CHECK (actual.find (' a' ) != std::string::npos);
137
161
CHECK (actual.find (' b' ) != std::string::npos);
@@ -140,11 +164,13 @@ TEST_CASE("add single parallel 3 with later dependency 2", "[graph_builder]") {
140
164
CHECK (actual.size () == 3 );
141
165
}
142
166
167
+ struct add_parallel_rhs {
168
+ constexpr static auto value = flow::graph<>{}.add(a >> (b && c));
169
+ };
143
170
TEST_CASE (" add parallel rhs" , " [graph_builder]" ) {
144
171
actual.clear ();
145
- auto g = flow::graph<>{}.add (a >> (b && c));
146
- auto const flow = builder::build (g);
147
- flow.value ()();
172
+ constexpr auto f = builder::render<add_parallel_rhs>();
173
+ f ();
148
174
149
175
CHECK (actual.find (' a' ) != std::string::npos);
150
176
CHECK (actual.find (' b' ) != std::string::npos);
@@ -154,11 +180,13 @@ TEST_CASE("add parallel rhs", "[graph_builder]") {
154
180
CHECK (actual.size () == 3 );
155
181
}
156
182
183
+ struct add_parallel_lhs {
184
+ constexpr static auto value = flow::graph<>{}.add((a && b) >> c);
185
+ };
157
186
TEST_CASE (" add parallel lhs" , " [graph_builder]" ) {
158
187
actual.clear ();
159
- auto g = flow::graph<>{}.add ((a && b) >> c);
160
- auto const flow = builder::build (g);
161
- flow.value ()();
188
+ constexpr auto f = builder::render<add_parallel_lhs>();
189
+ f ();
162
190
163
191
CHECK (actual.find (' a' ) != std::string::npos);
164
192
CHECK (actual.find (' b' ) != std::string::npos);
@@ -168,11 +196,13 @@ TEST_CASE("add parallel lhs", "[graph_builder]") {
168
196
CHECK (actual.size () == 3 );
169
197
}
170
198
199
+ struct add_parallel_in_the_middle {
200
+ constexpr static auto value = flow::graph<>{}.add(a >> (b && c) >> d);
201
+ };
171
202
TEST_CASE (" add parallel in the middle" , " [graph_builder]" ) {
172
203
actual.clear ();
173
- auto g = flow::graph<>{}.add (a >> (b && c) >> d);
174
- auto const flow = builder::build (g);
175
- flow.value ()();
204
+ constexpr auto f = builder::render<add_parallel_in_the_middle>();
205
+ f ();
176
206
177
207
CHECK (actual.find (' a' ) != std::string::npos);
178
208
CHECK (actual.find (' b' ) != std::string::npos);
@@ -188,11 +218,13 @@ TEST_CASE("add parallel in the middle", "[graph_builder]") {
188
218
CHECK (actual.size () == 4 );
189
219
}
190
220
221
+ struct add_dependency_lhs {
222
+ constexpr static auto value = flow::graph<>{}.add((a >> b) && c);
223
+ };
191
224
TEST_CASE (" add dependency lhs" , " [graph_builder]" ) {
192
225
actual.clear ();
193
- auto g = flow::graph<>{}.add ((a >> b) && c);
194
- auto const flow = builder::build (g);
195
- flow.value ()();
226
+ constexpr auto f = builder::render<add_dependency_lhs>();
227
+ f ();
196
228
197
229
CHECK (actual.find (' a' ) != std::string::npos);
198
230
CHECK (actual.find (' b' ) != std::string::npos);
@@ -203,11 +235,13 @@ TEST_CASE("add dependency lhs", "[graph_builder]") {
203
235
CHECK (actual.size () == 3 );
204
236
}
205
237
238
+ struct add_dependency_rhs {
239
+ constexpr static auto value = flow::graph<>{}.add(a && (b >> c));
240
+ };
206
241
TEST_CASE (" add dependency rhs" , " [graph_builder]" ) {
207
242
actual.clear ();
208
- auto g = flow::graph<>{}.add (a && (b >> c));
209
- auto const flow = builder::build (g);
210
- flow.value ()();
243
+ constexpr auto f = builder::render<add_dependency_rhs>();
244
+ f ();
211
245
212
246
CHECK (actual.find (' a' ) != std::string::npos);
213
247
CHECK (actual.find (' b' ) != std::string::npos);
0 commit comments