tstTimeSpec.cpp revision c73f7d585a4e0a070e4c43b86d159887334364a4
/* $Id$ */
/** @file
* InnoTek Portable Runtime - RTTimeSpec and PRTTIME tests.
*/
/*
* Copyright (C) 2006 InnoTek Systemberatung GmbH
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License as published by the Free Software Foundation,
* in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
* distribution. VirtualBox OSE is distributed in the hope that it will
* be useful, but WITHOUT ANY WARRANTY of any kind.
*
* If you received this file as part of a commercial VirtualBox
* distribution, then only the terms of your commercial VirtualBox
* license agreement apply instead of the previous paragraph.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
/**
* Format the time into a string using a static buffer.
*/
{
static char szBuf[128];
return szBuf;
}
#define CHECK_NZ(expr) do { if (!(expr)) { RTPrintf("tstTimeSpec: FAILURE at line %d: %#x\n", __LINE__, #expr); return 1; } } while (0)
{ \
RTPrintf("tstTimeSpec: FAILURE - %RI64 != %RI64\n", RTTimeSpecGetNano(&Ts2), RTTimeSpecGetNano(&Ts1)); \
return 1; \
} \
} while (0)
{ \
RTPrintf("tstTimeSpec: FAILURE - %RI64 != %RI64\n", RTTimeSpecGetNano(&Ts2), RTTimeSpecGetNano(&Ts1)); \
return 1; \
} \
} while (0)
#define CHECK_TIME(pTime, _i32Year, _u8Month, _u8MonthDay, _u8Hour, _u8Minute, _u8Second, _u32Nanosecond, _u16YearDay, _u8WeekDay, _fFlags)\
do { \
) \
{ \
RTPrintf("tstTimeSpec: FAILURE - %s\n" \
" != %04d-%02d-%02dT%02u-%02u-%02u.%09u [YD%u WD%u F%#x]\n", \
return 1; \
} \
} while (0)
int main()
{
//RTTIME T2;
/*
* Simple test with current time.
*/
{
RTPrintf("tstTimeSpec: FAILURE - %RI64 != %RI64\n", RTTimeSpecGetNano(&Ts1), RTTimeSpecGetNano(&Now));
return 1;
}
/*
* Simple test with current local time.
*/
{
RTPrintf("tstTimeSpec: FAILURE - %RI64 != %RI64\n", RTTimeSpecGetNano(&Ts1), RTTimeSpecGetNano(&Now));
return 1;
}
/*
* Some simple tests with fixed dates (just checking for smoke).
*/
CHECK_TIME(&T1, 1969,12,31, 23,59,59,999999999, 365, 2, RTTIME_FLAGS_TYPE_UTC | RTTIME_FLAGS_COMMON_YEAR);
/*
* Test the limits.
*/
TEST_SEC(1095379198);
TEST_SEC(1095379199);
TEST_SEC(1095379200);
TEST_SEC(1095379201);
RTPrintf("tstTimeSpec: SUCCESS\n");
return 0;
}