diff options
author | Mattias Andrée <maandree@kth.se> | 2018-08-26 14:31:09 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2018-08-26 14:31:09 +0200 |
commit | e59072005414970eda98dee2acf22487805e091c (patch) | |
tree | 6085a34dd8498063d4aa704b45fe8851ffe224b5 /libsimple.c | |
parent | Fix aliases (diff) | |
download | libsimple-e59072005414970eda98dee2acf22487805e091c.tar.gz libsimple-e59072005414970eda98dee2acf22487805e091c.tar.bz2 libsimple-e59072005414970eda98dee2acf22487805e091c.tar.xz |
Tests and fixes
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r-- | libsimple.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/libsimple.c b/libsimple.c index 15326d1..df01ea1 100644 --- a/libsimple.c +++ b/libsimple.c @@ -96,6 +96,7 @@ test_timeval(double d, time_t sec, long int usec, double rd, const char *s, cons int main(void) { + struct timespec ts; const char *cs; char buf[1024], *s; int intarray[10]; @@ -757,6 +758,28 @@ main(void) assert(test_timeval(0, 0, 0, 0, "+0.000000", "0")); assert(test_timeval(-10, -10, 0, -10, "-10.000000", "-10")); + libsimple_timeval2timespec(&ts, &(struct timeval){0, 0L}); + assert(ts.tv_sec == 0); + assert(ts.tv_nsec == 0L); + libsimple_timeval2timespec(&ts, &(struct timeval){0, 1L}); + assert(ts.tv_sec == 0); + assert(ts.tv_nsec == 1000L); + libsimple_timeval2timespec(&ts, &(struct timeval){0, 999999L}); + assert(ts.tv_sec == 0); + assert(ts.tv_nsec == 999999000L); + libsimple_timeval2timespec(&ts, &(struct timeval){10, 0L}); + assert(ts.tv_sec == 10); + assert(ts.tv_nsec == 0L); + libsimple_timeval2timespec(&ts, &(struct timeval){10, 1L}); + assert(ts.tv_sec == 10); + assert(ts.tv_nsec == 1000L); + libsimple_timeval2timespec(&ts, &(struct timeval){-10, 0L}); + assert(ts.tv_sec == -10); + assert(ts.tv_nsec == 0L); + libsimple_timeval2timespec(&ts, &(struct timeval){-10, 1L}); + assert(ts.tv_sec == -10); + assert(ts.tv_nsec == 1000L); + return 0; } |