aboutsummaryrefslogtreecommitdiffstats
path: root/libsimple.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--libsimple.c233
1 files changed, 232 insertions, 1 deletions
diff --git a/libsimple.c b/libsimple.c
index df01ea1..b27f3bb 100644
--- a/libsimple.c
+++ b/libsimple.c
@@ -96,7 +96,8 @@ test_timeval(double d, time_t sec, long int usec, double rd, const char *s, cons
int
main(void)
{
- struct timespec ts;
+ struct timespec ts, ts1, ts2;
+ struct timeval tv1, tv2;
const char *cs;
char buf[1024], *s;
int intarray[10];
@@ -780,6 +781,236 @@ main(void)
assert(ts.tv_sec == -10);
assert(ts.tv_nsec == 1000L);
+ ts1.tv_sec = 0, ts1.tv_nsec = 0L;
+ ts2.tv_sec = 0, ts2.tv_nsec = 0L;
+ assert(libsimple_cmptimespec(&ts1, &ts2) == 0);
+ ts1.tv_sec = 0, ts1.tv_nsec = 1L;
+ ts2.tv_sec = 0, ts2.tv_nsec = 0L;
+ assert(libsimple_cmptimespec(&ts1, &ts2) == 1);
+ ts1.tv_sec = 0, ts1.tv_nsec = 999999999L;
+ ts2.tv_sec = 0, ts2.tv_nsec = 0L;
+ assert(libsimple_cmptimespec(&ts1, &ts2) == 1);
+ ts1.tv_sec = 0, ts1.tv_nsec = 0L;
+ ts2.tv_sec = 0, ts2.tv_nsec = 1L;
+ assert(libsimple_cmptimespec(&ts1, &ts2) == -1);
+ ts1.tv_sec = 0, ts1.tv_nsec = 1L;
+ ts2.tv_sec = 0, ts2.tv_nsec = 1L;
+ assert(libsimple_cmptimespec(&ts1, &ts2) == 0);
+ ts1.tv_sec = 0, ts1.tv_nsec = 999999999L;
+ ts2.tv_sec = 0, ts2.tv_nsec = 1L;
+ assert(libsimple_cmptimespec(&ts1, &ts2) == 1);
+ ts1.tv_sec = 0, ts1.tv_nsec = 0L;
+ ts2.tv_sec = 0, ts2.tv_nsec = 999999999L;
+ assert(libsimple_cmptimespec(&ts1, &ts2) == -1);
+ ts1.tv_sec = 0, ts1.tv_nsec = 1L;
+ ts2.tv_sec = 0, ts2.tv_nsec = 999999999L;
+ assert(libsimple_cmptimespec(&ts1, &ts2) == -1);
+ ts1.tv_sec = 0, ts1.tv_nsec = 999999999L;
+ ts2.tv_sec = 0, ts2.tv_nsec = 999999999L;
+ assert(libsimple_cmptimespec(&ts1, &ts2) == 0);
+ ts1.tv_sec = 1, ts1.tv_nsec = 0L;
+ ts2.tv_sec = 0, ts2.tv_nsec = 0L;
+ assert(libsimple_cmptimespec(&ts1, &ts2) == 1);
+ ts1.tv_sec = 1, ts1.tv_nsec = 1L;
+ ts2.tv_sec = 0, ts2.tv_nsec = 0L;
+ assert(libsimple_cmptimespec(&ts1, &ts2) == 1);
+ ts1.tv_sec = 1, ts1.tv_nsec = 0L;
+ ts2.tv_sec = 0, ts2.tv_nsec = 1L;
+ assert(libsimple_cmptimespec(&ts1, &ts2) == 1);
+ ts1.tv_sec = 1, ts1.tv_nsec = 1L;
+ ts2.tv_sec = 0, ts2.tv_nsec = 1L;
+ assert(libsimple_cmptimespec(&ts1, &ts2) == 1);
+ ts1.tv_sec = 0, ts1.tv_nsec = 0L;
+ ts2.tv_sec = 1, ts2.tv_nsec = 0L;
+ assert(libsimple_cmptimespec(&ts1, &ts2) == -1);
+ ts1.tv_sec = 0, ts1.tv_nsec = 1L;
+ ts2.tv_sec = 1, ts2.tv_nsec = 0L;
+ assert(libsimple_cmptimespec(&ts1, &ts2) == -1);
+ ts1.tv_sec = 0, ts1.tv_nsec = 0L;
+ ts2.tv_sec = 1, ts2.tv_nsec = 1L;
+ assert(libsimple_cmptimespec(&ts1, &ts2) == -1);
+ ts1.tv_sec = 0, ts1.tv_nsec = 1L;
+ ts2.tv_sec = 1, ts2.tv_nsec = 1L;
+ assert(libsimple_cmptimespec(&ts1, &ts2) == -1);
+ ts1.tv_sec = 1, ts1.tv_nsec = 0L;
+ ts2.tv_sec = 1, ts2.tv_nsec = 0L;
+ assert(libsimple_cmptimespec(&ts1, &ts2) == 0);
+ ts1.tv_sec = 1, ts1.tv_nsec = 1L;
+ ts2.tv_sec = 1, ts2.tv_nsec = 0L;
+ assert(libsimple_cmptimespec(&ts1, &ts2) == 1);
+ ts1.tv_sec = 1, ts1.tv_nsec = 0L;
+ ts2.tv_sec = 1, ts2.tv_nsec = 1L;
+ assert(libsimple_cmptimespec(&ts1, &ts2) == -1);
+ ts1.tv_sec = 1, ts1.tv_nsec = 1L;
+ ts2.tv_sec = 1, ts2.tv_nsec = 1L;
+ assert(libsimple_cmptimespec(&ts1, &ts2) == 0);
+ ts1.tv_sec = -1, ts1.tv_nsec = 0L;
+ ts2.tv_sec = 0, ts2.tv_nsec = 0L;
+ assert(libsimple_cmptimespec(&ts1, &ts2) == -1);
+ ts1.tv_sec = -1, ts1.tv_nsec = 1L;
+ ts2.tv_sec = 0, ts2.tv_nsec = 0L;
+ assert(libsimple_cmptimespec(&ts1, &ts2) == -1);
+ ts1.tv_sec = -1, ts1.tv_nsec = 0L;
+ ts2.tv_sec = 0, ts2.tv_nsec = 1L;
+ assert(libsimple_cmptimespec(&ts1, &ts2) == -1);
+ ts1.tv_sec = -1, ts1.tv_nsec = 1L;
+ ts2.tv_sec = 0, ts2.tv_nsec = 1L;
+ assert(libsimple_cmptimespec(&ts1, &ts2) == -1);
+ ts1.tv_sec = 0, ts1.tv_nsec = 0L;
+ ts2.tv_sec = -1, ts2.tv_nsec = 0L;
+ assert(libsimple_cmptimespec(&ts1, &ts2) == 1);
+ ts1.tv_sec = 0, ts1.tv_nsec = 1L;
+ ts2.tv_sec = -1, ts2.tv_nsec = 0L;
+ assert(libsimple_cmptimespec(&ts1, &ts2) == 1);
+ ts1.tv_sec = 0, ts1.tv_nsec = 0L;
+ ts2.tv_sec = -1, ts2.tv_nsec = 1L;
+ assert(libsimple_cmptimespec(&ts1, &ts2) == 1);
+ ts1.tv_sec = 0, ts1.tv_nsec = 1L;
+ ts2.tv_sec = -1, ts2.tv_nsec = 1L;
+ assert(libsimple_cmptimespec(&ts1, &ts2) == 1);
+ ts1.tv_sec = -1, ts1.tv_nsec = 0L;
+ ts2.tv_sec = -1, ts2.tv_nsec = 0L;
+ assert(libsimple_cmptimespec(&ts1, &ts2) == 0);
+ ts1.tv_sec = -1, ts1.tv_nsec = 1L;
+ ts2.tv_sec = -1, ts2.tv_nsec = 0L;
+ assert(libsimple_cmptimespec(&ts1, &ts2) == 1);
+ ts1.tv_sec = -1, ts1.tv_nsec = 0L;
+ ts2.tv_sec = -1, ts2.tv_nsec = 1L;
+ assert(libsimple_cmptimespec(&ts1, &ts2) == -1);
+ ts1.tv_sec = -1, ts1.tv_nsec = 1L;
+ ts2.tv_sec = -1, ts2.tv_nsec = 1L;
+ assert(libsimple_cmptimespec(&ts1, &ts2) == 0);
+ ts1.tv_sec = 0, ts1.tv_nsec = 0L;
+ ts2.tv_sec = TIME_MAX, ts2.tv_nsec = 0L;
+ assert(libsimple_cmptimespec(&ts1, &ts2) == -1);
+ ts1.tv_sec = 1, ts1.tv_nsec = 0L;
+ ts2.tv_sec = TIME_MAX, ts2.tv_nsec = 0L;
+ assert(libsimple_cmptimespec(&ts1, &ts2) == -1);
+ ts1.tv_sec = TIME_MAX, ts1.tv_nsec = 0L;
+ ts2.tv_sec = TIME_MAX, ts2.tv_nsec = 0L;
+ assert(libsimple_cmptimespec(&ts1, &ts2) == 0);
+ ts1.tv_sec = 1, ts1.tv_nsec = 0L;
+ ts2.tv_sec = -1, ts2.tv_nsec = 0L;
+ assert(libsimple_cmptimespec(&ts1, &ts2) == 1);
+ ts1.tv_sec = -1, ts1.tv_nsec = 0L;
+ ts2.tv_sec = 1, ts2.tv_nsec = 0L;
+ assert(libsimple_cmptimespec(&ts1, &ts2) == -1);
+
+ tv1.tv_sec = 0, tv1.tv_usec = 0L;
+ tv2.tv_sec = 0, tv2.tv_usec = 0L;
+ assert(libsimple_cmptimeval(&tv1, &tv2) == 0);
+ tv1.tv_sec = 0, tv1.tv_usec = 1L;
+ tv2.tv_sec = 0, tv2.tv_usec = 0L;
+ assert(libsimple_cmptimeval(&tv1, &tv2) == 1);
+ tv1.tv_sec = 0, tv1.tv_usec = 999999L;
+ tv2.tv_sec = 0, tv2.tv_usec = 0L;
+ assert(libsimple_cmptimeval(&tv1, &tv2) == 1);
+ tv1.tv_sec = 0, tv1.tv_usec = 0L;
+ tv2.tv_sec = 0, tv2.tv_usec = 1L;
+ assert(libsimple_cmptimeval(&tv1, &tv2) == -1);
+ tv1.tv_sec = 0, tv1.tv_usec = 1L;
+ tv2.tv_sec = 0, tv2.tv_usec = 1L;
+ assert(libsimple_cmptimeval(&tv1, &tv2) == 0);
+ tv1.tv_sec = 0, tv1.tv_usec = 999999L;
+ tv2.tv_sec = 0, tv2.tv_usec = 1L;
+ assert(libsimple_cmptimeval(&tv1, &tv2) == 1);
+ tv1.tv_sec = 0, tv1.tv_usec = 0L;
+ tv2.tv_sec = 0, tv2.tv_usec = 999999L;
+ assert(libsimple_cmptimeval(&tv1, &tv2) == -1);
+ tv1.tv_sec = 0, tv1.tv_usec = 1L;
+ tv2.tv_sec = 0, tv2.tv_usec = 999999L;
+ assert(libsimple_cmptimeval(&tv1, &tv2) == -1);
+ tv1.tv_sec = 0, tv1.tv_usec = 999999L;
+ tv2.tv_sec = 0, tv2.tv_usec = 999999L;
+ assert(libsimple_cmptimeval(&tv1, &tv2) == 0);
+ tv1.tv_sec = 1, tv1.tv_usec = 0L;
+ tv2.tv_sec = 0, tv2.tv_usec = 0L;
+ assert(libsimple_cmptimeval(&tv1, &tv2) == 1);
+ tv1.tv_sec = 1, tv1.tv_usec = 1L;
+ tv2.tv_sec = 0, tv2.tv_usec = 0L;
+ assert(libsimple_cmptimeval(&tv1, &tv2) == 1);
+ tv1.tv_sec = 1, tv1.tv_usec = 0L;
+ tv2.tv_sec = 0, tv2.tv_usec = 1L;
+ assert(libsimple_cmptimeval(&tv1, &tv2) == 1);
+ tv1.tv_sec = 1, tv1.tv_usec = 1L;
+ tv2.tv_sec = 0, tv2.tv_usec = 1L;
+ assert(libsimple_cmptimeval(&tv1, &tv2) == 1);
+ tv1.tv_sec = 0, tv1.tv_usec = 0L;
+ tv2.tv_sec = 1, tv2.tv_usec = 0L;
+ assert(libsimple_cmptimeval(&tv1, &tv2) == -1);
+ tv1.tv_sec = 0, tv1.tv_usec = 1L;
+ tv2.tv_sec = 1, tv2.tv_usec = 0L;
+ assert(libsimple_cmptimeval(&tv1, &tv2) == -1);
+ tv1.tv_sec = 0, tv1.tv_usec = 0L;
+ tv2.tv_sec = 1, tv2.tv_usec = 1L;
+ assert(libsimple_cmptimeval(&tv1, &tv2) == -1);
+ tv1.tv_sec = 0, tv1.tv_usec = 1L;
+ tv2.tv_sec = 1, tv2.tv_usec = 1L;
+ assert(libsimple_cmptimeval(&tv1, &tv2) == -1);
+ tv1.tv_sec = 1, tv1.tv_usec = 0L;
+ tv2.tv_sec = 1, tv2.tv_usec = 0L;
+ assert(libsimple_cmptimeval(&tv1, &tv2) == 0);
+ tv1.tv_sec = 1, tv1.tv_usec = 1L;
+ tv2.tv_sec = 1, tv2.tv_usec = 0L;
+ assert(libsimple_cmptimeval(&tv1, &tv2) == 1);
+ tv1.tv_sec = 1, tv1.tv_usec = 0L;
+ tv2.tv_sec = 1, tv2.tv_usec = 1L;
+ assert(libsimple_cmptimeval(&tv1, &tv2) == -1);
+ tv1.tv_sec = 1, tv1.tv_usec = 1L;
+ tv2.tv_sec = 1, tv2.tv_usec = 1L;
+ assert(libsimple_cmptimeval(&tv1, &tv2) == 0);
+ tv1.tv_sec = -1, tv1.tv_usec = 0L;
+ tv2.tv_sec = 0, tv2.tv_usec = 0L;
+ assert(libsimple_cmptimeval(&tv1, &tv2) == -1);
+ tv1.tv_sec = -1, tv1.tv_usec = 1L;
+ tv2.tv_sec = 0, tv2.tv_usec = 0L;
+ assert(libsimple_cmptimeval(&tv1, &tv2) == -1);
+ tv1.tv_sec = -1, tv1.tv_usec = 0L;
+ tv2.tv_sec = 0, tv2.tv_usec = 1L;
+ assert(libsimple_cmptimeval(&tv1, &tv2) == -1);
+ tv1.tv_sec = -1, tv1.tv_usec = 1L;
+ tv2.tv_sec = 0, tv2.tv_usec = 1L;
+ assert(libsimple_cmptimeval(&tv1, &tv2) == -1);
+ tv1.tv_sec = 0, tv1.tv_usec = 0L;
+ tv2.tv_sec = -1, tv2.tv_usec = 0L;
+ assert(libsimple_cmptimeval(&tv1, &tv2) == 1);
+ tv1.tv_sec = 0, tv1.tv_usec = 1L;
+ tv2.tv_sec = -1, tv2.tv_usec = 0L;
+ assert(libsimple_cmptimeval(&tv1, &tv2) == 1);
+ tv1.tv_sec = 0, tv1.tv_usec = 0L;
+ tv2.tv_sec = -1, tv2.tv_usec = 1L;
+ assert(libsimple_cmptimeval(&tv1, &tv2) == 1);
+ tv1.tv_sec = 0, tv1.tv_usec = 1L;
+ tv2.tv_sec = -1, tv2.tv_usec = 1L;
+ assert(libsimple_cmptimeval(&tv1, &tv2) == 1);
+ tv1.tv_sec = -1, tv1.tv_usec = 0L;
+ tv2.tv_sec = -1, tv2.tv_usec = 0L;
+ assert(libsimple_cmptimeval(&tv1, &tv2) == 0);
+ tv1.tv_sec = -1, tv1.tv_usec = 1L;
+ tv2.tv_sec = -1, tv2.tv_usec = 0L;
+ assert(libsimple_cmptimeval(&tv1, &tv2) == 1);
+ tv1.tv_sec = -1, tv1.tv_usec = 0L;
+ tv2.tv_sec = -1, tv2.tv_usec = 1L;
+ assert(libsimple_cmptimeval(&tv1, &tv2) == -1);
+ tv1.tv_sec = -1, tv1.tv_usec = 1L;
+ tv2.tv_sec = -1, tv2.tv_usec = 1L;
+ assert(libsimple_cmptimeval(&tv1, &tv2) == 0);
+ tv1.tv_sec = 0, tv1.tv_usec = 0L;
+ tv2.tv_sec = TIME_MAX, tv2.tv_usec = 0L;
+ assert(libsimple_cmptimeval(&tv1, &tv2) == -1);
+ tv1.tv_sec = 1, tv1.tv_usec = 0L;
+ tv2.tv_sec = TIME_MAX, tv2.tv_usec = 0L;
+ assert(libsimple_cmptimeval(&tv1, &tv2) == -1);
+ tv1.tv_sec = TIME_MAX, tv1.tv_usec = 0L;
+ tv2.tv_sec = TIME_MAX, tv2.tv_usec = 0L;
+ assert(libsimple_cmptimeval(&tv1, &tv2) == 0);
+ tv1.tv_sec = 1, tv1.tv_usec = 0L;
+ tv2.tv_sec = -1, tv2.tv_usec = 0L;
+ assert(libsimple_cmptimeval(&tv1, &tv2) == 1);
+ tv1.tv_sec = -1, tv1.tv_usec = 0L;
+ tv2.tv_sec = 1, tv2.tv_usec = 0L;
+ assert(libsimple_cmptimeval(&tv1, &tv2) == -1);
+
return 0;
}