5
5
6
6
#include < test/3rd_party/utest_helper/helper.hpp>
7
7
8
+ using namespace std ::chrono_literals;
9
+
8
10
namespace tests = so_5::experimental::testing::v1;
9
11
10
12
struct hello_1 final : public so_5::signal_t {};
@@ -55,19 +57,18 @@ UT_UNIT_TEST( not_before_1 )
55
57
{
56
58
tests::testing_env_t env;
57
59
58
- so_5::agent_t * test_agent;
59
- env.environment ().introduce_coop ( [&](so_5::coop_t & coop) {
60
- test_agent = coop.make_agent < test_agent_t >(
61
- std::chrono::milliseconds (200 ) );
60
+ so_5::agent_t * test_agent = env.environment ().introduce_coop (
61
+ [&](so_5::coop_t & coop) {
62
+ return coop.make_agent < test_agent_t >( 200ms );
62
63
} );
63
64
64
65
define_hello_1_step ( env, *test_agent );
65
66
66
67
env.scenario ().define_step ( " hello_2" )
67
- .constraints ( tests::not_before ( std::chrono::milliseconds ( 500 ) ) )
68
+ .constraints ( tests::not_before ( 500ms ) )
68
69
.when ( *test_agent & tests::reacts_to<hello_2>() );
69
70
70
- env.scenario ().run_for ( std::chrono::milliseconds ( 1000 ) );
71
+ env.scenario ().run_for ( 1000ms );
71
72
72
73
UT_CHECK_NE ( tests::completed (), env.scenario ().result () );
73
74
},
@@ -81,19 +82,18 @@ UT_UNIT_TEST( not_before_2 )
81
82
{
82
83
tests::testing_env_t env;
83
84
84
- so_5::agent_t * test_agent;
85
- env.environment ().introduce_coop ( [&](so_5::coop_t & coop) {
86
- test_agent = coop.make_agent < test_agent_t >(
87
- std::chrono::milliseconds (700 ) );
85
+ so_5::agent_t * test_agent = env.environment ().introduce_coop (
86
+ [](so_5::coop_t & coop) {
87
+ return coop.make_agent < test_agent_t >( 700ms );
88
88
} );
89
89
90
90
define_hello_1_step ( env, *test_agent );
91
91
92
92
env.scenario ().define_step ( " hello_2" )
93
- .constraints ( tests::not_before ( std::chrono::milliseconds ( 300 ) ) )
93
+ .constraints ( tests::not_before ( 300ms ) )
94
94
.when ( *test_agent & tests::reacts_to<hello_2>() );
95
95
96
- env.scenario ().run_for ( std::chrono::milliseconds ( 1000 ) );
96
+ env.scenario ().run_for ( 1000ms );
97
97
98
98
UT_CHECK_EQ ( tests::completed (), env.scenario ().result () );
99
99
},
@@ -107,19 +107,18 @@ UT_UNIT_TEST( not_after_1 )
107
107
{
108
108
tests::testing_env_t env;
109
109
110
- so_5::agent_t * test_agent;
111
- env.environment ().introduce_coop ( [&](so_5::coop_t & coop) {
112
- test_agent = coop.make_agent < test_agent_t >(
113
- std::chrono::milliseconds (200 ) );
110
+ so_5::agent_t * test_agent = env.environment ().introduce_coop (
111
+ [](so_5::coop_t & coop) {
112
+ return coop.make_agent < test_agent_t >( 200ms );
114
113
} );
115
114
116
115
define_hello_1_step ( env, *test_agent );
117
116
118
117
env.scenario ().define_step ( " hello_2" )
119
- .constraints ( tests::not_after ( std::chrono::milliseconds ( 400 ) ) )
118
+ .constraints ( tests::not_after ( 400ms ) )
120
119
.when ( *test_agent & tests::reacts_to<hello_2>() );
121
120
122
- env.scenario ().run_for ( std::chrono::milliseconds ( 1000 ) );
121
+ env.scenario ().run_for ( 1000ms );
123
122
124
123
UT_CHECK_EQ ( tests::completed (), env.scenario ().result () );
125
124
},
@@ -133,19 +132,18 @@ UT_UNIT_TEST( not_after_2 )
133
132
{
134
133
tests::testing_env_t env;
135
134
136
- so_5::agent_t * test_agent;
137
- env.environment ().introduce_coop ( [&](so_5::coop_t & coop) {
138
- test_agent = coop.make_agent < test_agent_t >(
139
- std::chrono::milliseconds (500 ) );
135
+ so_5::agent_t * test_agent = env.environment ().introduce_coop (
136
+ [](so_5::coop_t & coop) {
137
+ return coop.make_agent < test_agent_t >( 500ms );
140
138
} );
141
139
142
140
define_hello_1_step ( env, *test_agent );
143
141
144
142
env.scenario ().define_step ( " hello_2" )
145
- .constraints ( tests::not_after ( std::chrono::milliseconds ( 250 ) ) )
143
+ .constraints ( tests::not_after ( 250ms ) )
146
144
.when ( *test_agent & tests::reacts_to<hello_2>() );
147
145
148
- env.scenario ().run_for ( std::chrono::milliseconds ( 1000 ) );
146
+ env.scenario ().run_for ( 1000ms );
149
147
150
148
UT_CHECK_NE ( tests::completed (), env.scenario ().result () );
151
149
},
@@ -159,21 +157,20 @@ UT_UNIT_TEST( not_before_not_after_1 )
159
157
{
160
158
tests::testing_env_t env;
161
159
162
- so_5::agent_t * test_agent;
163
- env.environment ().introduce_coop ( [&](so_5::coop_t & coop) {
164
- test_agent = coop.make_agent < test_agent_t >(
165
- std::chrono::milliseconds (200 ) );
160
+ so_5::agent_t * test_agent = env.environment ().introduce_coop (
161
+ [](so_5::coop_t & coop) {
162
+ return coop.make_agent < test_agent_t >( 200ms );
166
163
} );
167
164
168
165
define_hello_1_step ( env, *test_agent );
169
166
170
167
env.scenario ().define_step ( " hello_2" )
171
168
.constraints (
172
- tests::not_before ( std::chrono::milliseconds ( 400 ) ),
173
- tests::not_after ( std::chrono::milliseconds ( 600 ) ) )
169
+ tests::not_before ( 400ms ),
170
+ tests::not_after ( 600ms ) )
174
171
.when ( *test_agent & tests::reacts_to<hello_2>() );
175
172
176
- env.scenario ().run_for ( std::chrono::milliseconds ( 1000 ) );
173
+ env.scenario ().run_for ( 1000ms );
177
174
178
175
UT_CHECK_NE ( tests::completed (), env.scenario ().result () );
179
176
},
@@ -187,21 +184,20 @@ UT_UNIT_TEST( not_before_not_after_2 )
187
184
{
188
185
tests::testing_env_t env;
189
186
190
- so_5::agent_t * test_agent;
191
- env.environment ().introduce_coop ( [&](so_5::coop_t & coop) {
192
- test_agent = coop.make_agent < test_agent_t >(
193
- std::chrono::milliseconds (400 ) );
187
+ so_5::agent_t * test_agent = env.environment ().introduce_coop (
188
+ [](so_5::coop_t & coop) {
189
+ return coop.make_agent < test_agent_t >( 400ms );
194
190
} );
195
191
196
192
define_hello_1_step ( env, *test_agent );
197
193
198
194
env.scenario ().define_step ( " hello_2" )
199
195
.constraints (
200
- tests::not_before ( std::chrono::milliseconds ( 150 ) ),
201
- tests::not_after ( std::chrono::milliseconds ( 200 ) ) )
196
+ tests::not_before ( 150ms ),
197
+ tests::not_after ( 200ms ) )
202
198
.when ( *test_agent & tests::reacts_to<hello_2>() );
203
199
204
- env.scenario ().run_for ( std::chrono::milliseconds ( 1000 ) );
200
+ env.scenario ().run_for ( 1000ms );
205
201
206
202
UT_CHECK_NE ( tests::completed (), env.scenario ().result () );
207
203
},
@@ -215,21 +211,20 @@ UT_UNIT_TEST( not_before_not_after_3 )
215
211
{
216
212
tests::testing_env_t env;
217
213
218
- so_5::agent_t * test_agent;
219
- env.environment ().introduce_coop ( [&](so_5::coop_t & coop) {
220
- test_agent = coop.make_agent < test_agent_t >(
221
- std::chrono::milliseconds (250 ) );
214
+ so_5::agent_t * test_agent = env.environment ().introduce_coop (
215
+ [](so_5::coop_t & coop) {
216
+ return coop.make_agent < test_agent_t >( 250ms );
222
217
} );
223
218
224
219
define_hello_1_step ( env, *test_agent );
225
220
226
221
env.scenario ().define_step ( " hello_2" )
227
222
.constraints (
228
- tests::not_before ( std::chrono::milliseconds ( 100 ) ),
229
- tests::not_after ( std::chrono::milliseconds ( 500 ) ) )
223
+ tests::not_before ( 100ms ),
224
+ tests::not_after ( 500ms ) )
230
225
.when ( *test_agent & tests::reacts_to<hello_2>() );
231
226
232
- env.scenario ().run_for ( std::chrono::milliseconds ( 1000 ) );
227
+ env.scenario ().run_for ( 1000ms );
233
228
234
229
UT_CHECK_EQ ( tests::completed (), env.scenario ().result () );
235
230
},
0 commit comments