From a93061c18c24ec1d4cd955b19f879b0ff828af41 Mon Sep 17 00:00:00 2001 From: Kolan Sh Date: Thu, 8 Dec 2011 12:34:07 +0300 Subject: [PATCH] struct to struct conversions --- c/timeconv_test/timeconv_test.c | 38 ++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/c/timeconv_test/timeconv_test.c b/c/timeconv_test/timeconv_test.c index ee628c0..c840c79 100644 --- a/c/timeconv_test/timeconv_test.c +++ b/c/timeconv_test/timeconv_test.c @@ -5,13 +5,13 @@ #include "timeconv.h" -void conv_test() +void pack_conv_test() { struct tm t; struct timeval tv; struct timespec ts; struct timecent tc; - struct timemil tl; + struct timemils tl; uint64_t pack64 = 0; char buf[256]; size_t i = 0; @@ -48,10 +48,10 @@ void conv_test() memset(&tc, 0, sizeof(tc)); tc = timecent_from_csec(pack64); break; - case 3: pack64 = msec_from_timemil(tl); + case 3: pack64 = msec_from_timemils(tl); tl.tv_msec = 798431; memset(&tl, 0, sizeof(tl)); - tl = timemil_from_msec(pack64); + tl = timemils_from_msec(pack64); break; default:; } @@ -60,9 +60,37 @@ void conv_test() } } +void struct_conv_test() +{ + struct timeval tv; + struct timespec ts; + struct timecent tc; + struct timemils tl; + + tv = timeval_from_timespec(ts); + ts = timespec_from_timeval(tv); + + tv = timeval_from_timecent(tc); + tc = timecent_from_timeval(tv); + + tv = timeval_from_timemils(tl); + tl = timemils_from_timeval(tv); + + ts = timespec_from_timecent(tc); + tc = timecent_from_timespec(ts); + + ts = timespec_from_timemils(tl); + tl = timemils_from_timespec(ts); + + tc = timecent_from_timemils(tl); + tl = timemils_from_timecent(tc); +} + int main(int argc, char *argv[]) { - conv_test(); + pack_conv_test(); + + struct_conv_test(); return 0; }