aboutsummaryrefslogtreecommitdiff
path: root/tests/time
diff options
context:
space:
mode:
authormax99x <max99x@gmail.com>2011-07-08 09:07:44 +0300
committermax99x <max99x@gmail.com>2011-07-08 09:14:26 +0300
commitb5b48bab8bddb23a80031897d97f8942e702787a (patch)
tree0887142ed2bb9d3a2329e32e8a26308eed525992 /tests/time
parentb37b05b1a060ba56823073921f7988ea80f59e5c (diff)
Improved clock() test to verify time() <-> clock().
Diffstat (limited to 'tests/time')
-rw-r--r--tests/time/src.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/tests/time/src.c b/tests/time/src.c
index 94eb6a3f..9517b74c 100644
--- a/tests/time/src.c
+++ b/tests/time/src.c
@@ -92,10 +92,11 @@ int main() {
printf("old asctime again: %s", formatted);
// Verify that clock() advances.
+ time_t start_t = time(NULL);
clock_t start = clock();
printf("clock(start): %d\n", start >= 0);
- while (clock() - start < 50000); // Poor man's sleep().
- printf("clock(end): %d\n", clock() - start >= 50000);
+ while (clock() - start < 2 * CLOCKS_PER_SEC); // Poor man's sleep().
+ printf("clock(end): %d\n", time(NULL) - start_t == 2);
// Verify that ctime_r(x, buf) is equivalent to asctime_r(localtime(x), buf).
time_t t7 = time(0);