@@ -160,7 +160,14 @@ mod test {
160
160
let absolute_tolerance = expected_value * tolerance;
161
161
if expected_value >= 0.0 {
162
162
assert ! ( expected_value - absolute_tolerance < value) ;
163
- assert ! ( expected_value + absolute_tolerance > value) ;
163
+ assert ! (
164
+ expected_value + absolute_tolerance > value,
165
+ "{:.1} + {:.1} == {:.1} > {:.1}" ,
166
+ expected_value / 1_000_000.0 ,
167
+ absolute_tolerance / 1_000_000.0 ,
168
+ ( expected_value + absolute_tolerance) / 1_000_000.0 ,
169
+ value / 1_000_000.0
170
+ ) ;
164
171
} else {
165
172
assert ! ( expected_value - absolute_tolerance > value) ;
166
173
assert ! ( expected_value + absolute_tolerance < value) ;
@@ -290,17 +297,23 @@ mod test {
290
297
assert_eq ! ( OpenResult :: WINNER , open_info. result) ;
291
298
292
299
let expected_first_checkpoint = Duration :: from_millis ( SLEEPING_MILLIS ) . as_nanos ( ) as f64 ;
293
- check_close_to ( expected_first_checkpoint, elapsed_first_checkpoint, 0.1 ) ;
300
+ const HUGE_TOLERANCE_DUE_TO_TINY_SLEEP_TIME : f64 = 0.5 ;
301
+ check_close_to (
302
+ expected_first_checkpoint,
303
+ elapsed_first_checkpoint,
304
+ HUGE_TOLERANCE_DUE_TO_TINY_SLEEP_TIME ,
305
+ ) ;
294
306
295
307
thread:: sleep ( Duration :: from_millis ( SLEEPING_MILLIS ) ) ;
296
308
297
309
let expected_game_time = end_time - start_time;
298
310
let actual_game_time = game. get_elapsed ( ) ;
299
311
312
+ const BIG_TOLERANCE_DUE_TO_TINY_SLEEP_TIME : f64 = 0.3 ;
300
313
check_close_to (
301
314
expected_game_time. as_nanos ( ) as f64 ,
302
315
actual_game_time. as_nanos ( ) as f64 ,
303
- 0.1 ,
316
+ BIG_TOLERANCE_DUE_TO_TINY_SLEEP_TIME ,
304
317
) ;
305
318
306
319
assert_eq ! ( actual_game_time, game. get_elapsed( ) ) ;
0 commit comments