3
3
* <http://github.com/mity/acutest>
4
4
*
5
5
* Copyright (c) 2013-2019 Martin Mitas
6
+ * Copyright 2019 Garrett D'Amore
6
7
*
7
8
* Permission is hereby granted, free of charge, to any person obtaining a
8
9
* copy of this software and associated documentation files (the "Software"),
178
179
* the last test case after exiting the loop), you may use TEST_CASE(NULL).
179
180
*/
180
181
#define TEST_CASE_ (...) test_case__(__VA_ARGS__)
181
- #define TEST_CASE (name ) test_case__(" %s" , name);
182
+ #define TEST_CASE (name ) test_case__(" %s" , name)
182
183
183
184
184
185
/* printf-like macro for outputting an extra information about a failure.
@@ -364,8 +365,8 @@ static jmp_buf test_abort_jmp_buf__;
364
365
static double
365
366
test_timer_diff__ (LARGE_INTEGER start, LARGE_INTEGER end)
366
367
{
367
- double duration = end.QuadPart - start.QuadPart ;
368
- duration /= test_timer_freq__.QuadPart ;
368
+ double duration = ( double )( end.QuadPart - start.QuadPart ) ;
369
+ duration /= ( double ) test_timer_freq__.QuadPart ;
369
370
return duration;
370
371
}
371
372
@@ -384,12 +385,7 @@ static jmp_buf test_abort_jmp_buf__;
384
385
test_timer_init__ (void )
385
386
{
386
387
if (test_timer__ == 1 )
387
- #ifdef CLOCK_MONOTONIC_RAW
388
- /* linux specific; not subject of NTP adjustments or adjtime() */
389
- test_timer_id__ = CLOCK_MONOTONIC_RAW;
390
- #else
391
388
test_timer_id__ = CLOCK_MONOTONIC;
392
- #endif
393
389
else if (test_timer__ == 2 )
394
390
test_timer_id__ = CLOCK_PROCESS_CPUTIME_ID;
395
391
}
@@ -403,11 +399,18 @@ static jmp_buf test_abort_jmp_buf__;
403
399
static double
404
400
test_timer_diff__ (struct timespec start, struct timespec end)
405
401
{
406
- return ((double ) end.tv_sec +
407
- (double ) end.tv_nsec * 10e-9 )
408
- -
409
- ((double ) start.tv_sec +
410
- (double ) start.tv_nsec * 10e-9 );
402
+ double endns;
403
+ double startns;
404
+
405
+ endns = end.tv_sec ;
406
+ endns *= 1e9 ;
407
+ endns += end.tv_nsec ;
408
+
409
+ startns = start.tv_sec ;
410
+ startns *= 1e9 ;
411
+ startns += start.tv_nsec ;
412
+
413
+ return ((endns - startns)/ 1e9 );
411
414
}
412
415
413
416
static void
0 commit comments