Add test with 3 and 5 seconds.

This commit is contained in:
Andreas Schneider 2008-05-20 14:26:37 +02:00
Родитель 5a77997d55
Коммит 891827a48a
1 изменённых файлов: 34 добавлений и 1 удалений

Просмотреть файл

@ -1,4 +1,5 @@
#include <string.h>
#include <unistd.h>
#include "support.h"
@ -18,6 +19,21 @@ START_TEST (check_c_tspecdiff)
}
END_TEST
START_TEST (check_c_tspecdiff_five)
{
struct timespec start, finish, diff;
clock_gettime(CLOCK_REALTIME, &start);
sleep(5);
clock_gettime(CLOCK_REALTIME, &finish);
diff = c_tspecdiff(finish, start);
fail_unless(diff.tv_sec == 5, NULL);
fail_unless(diff.tv_nsec > 0, NULL);
}
END_TEST
START_TEST (check_c_secdiff)
{
struct timespec start, finish;
@ -28,7 +44,22 @@ START_TEST (check_c_secdiff)
diff = c_secdiff(finish, start);
fail_unless(diff > 0.00 && diff < 1.00, NULL);
fail_unless(diff > 0.00 && diff < 1.00, "diff is %.2f", diff);
}
END_TEST
START_TEST (check_c_secdiff_three)
{
struct timespec start, finish;
double diff;
clock_gettime(CLOCK_REALTIME, &start);
sleep(3);
clock_gettime(CLOCK_REALTIME, &finish);
diff = c_secdiff(finish, start);
fail_unless(diff > 3.00 && diff < 4.00, "diff is %.2f", diff);
}
END_TEST
@ -36,7 +67,9 @@ static Suite *make_std_c_suite(void) {
Suite *s = suite_create("std:path:c_basename");
create_case(s, "check_c_tspecdiff", check_c_tspecdiff);
create_case(s, "check_c_tspecdiff_five", check_c_tspecdiff_five);
create_case(s, "check_c_secdiff", check_c_secdiff);
create_case(s, "check_c_secdiff_three", check_c_secdiff_three);
return s;
}