struct to struct conversions

This commit is contained in:
Kolan Sh 2011-12-08 12:34:07 +03:00
parent 9c742c0137
commit a93061c18c
1 changed files with 33 additions and 5 deletions

View File

@ -5,13 +5,13 @@
#include "timeconv.h" #include "timeconv.h"
void conv_test() void pack_conv_test()
{ {
struct tm t; struct tm t;
struct timeval tv; struct timeval tv;
struct timespec ts; struct timespec ts;
struct timecent tc; struct timecent tc;
struct timemil tl; struct timemils tl;
uint64_t pack64 = 0; uint64_t pack64 = 0;
char buf[256]; char buf[256];
size_t i = 0; size_t i = 0;
@ -48,10 +48,10 @@ void conv_test()
memset(&tc, 0, sizeof(tc)); memset(&tc, 0, sizeof(tc));
tc = timecent_from_csec(pack64); tc = timecent_from_csec(pack64);
break; break;
case 3: pack64 = msec_from_timemil(tl); case 3: pack64 = msec_from_timemils(tl);
tl.tv_msec = 798431; tl.tv_msec = 798431;
memset(&tl, 0, sizeof(tl)); memset(&tl, 0, sizeof(tl));
tl = timemil_from_msec(pack64); tl = timemils_from_msec(pack64);
break; break;
default:; 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[]) int main(int argc, char *argv[])
{ {
conv_test(); pack_conv_test();
struct_conv_test();
return 0; return 0;
} }