56 TestUtil testFramework(
"UnixTime",
"Constructor", __FILE__, __LINE__ );
64 testFramework.
assert(1350000 == Compare.
tv.tv_sec,
"Explicit constructor did not set the tv_sec value properly", __LINE__);
65 testFramework.
assert(1 == Compare.
tv.tv_usec,
"Explicit constructor did not set the tv_usec value properly", __LINE__);
74 testFramework.
assert(1350000 == Copy.
tv.tv_sec,
"Copy constructor did not set the tv_sec value properly", __LINE__);
75 testFramework.
assert(1 == Copy.
tv.tv_usec,
"Copy constructor did not set the tv_usec value properly", __LINE__);
84 testFramework.
assert(1350000 == Assigned.
tv.tv_sec,
"Set Operator did not set the tv_sec value properly", __LINE__);
85 testFramework.
assert(1 == Assigned.
tv.tv_usec,
"Set Operator did not set the tv_usec value properly", __LINE__);
99 TestUtil testFramework(
"UnixTime",
"setFromInfo", __FILE__, __LINE__ );
115 testFramework.
assert(setFromInfo1.
setFromInfo(Id),
"setFromInfo experienced an error and returned false", __LINE__);
116 testFramework.
assert(Compare == setFromInfo1,
"setFromInfo did not set all of the values properly", __LINE__);
123 testFramework.
assert(setFromInfo2.
setFromInfo(Id),
"setFromInfo experienced an error and returned false", __LINE__);
124 testFramework.
assert(Compare2 == setFromInfo2,
"setFromInfo did not set all of the values properly", __LINE__);
137 TestUtil testFramework(
"UnixTime",
"OperatorEquivalent", __FILE__, __LINE__ );
142 UnixTime LessThanMicroSec(1350000,0);
148 testFramework.
assert( Compare == CompareCopy ,
"Equivalence operator found equivalent objects to not be equivalent", __LINE__);
149 testFramework.
assert(!(Compare == LessThanSec),
"Equivalence operator found different second objects to be equivalent", __LINE__);
150 testFramework.
assert(!(Compare == LessThanMicroSec),
"Equivalence operator found different microsecond objects to be equivalent", __LINE__);
155 testFramework.
assert(!(Compare != CompareCopy),
"Not-equal operator found equivalent objects to be not equivalent", __LINE__);
156 testFramework.
assert( Compare != LessThanSec ,
"Not-equal operator found different second objects to be equivalent", __LINE__);
157 testFramework.
assert( Compare != LessThanMicroSec ,
"Not-equal operator found different microsecond objects to be equivalent", __LINE__);
164 testFramework.
assert( LessThanSec < Compare ,
"Less-than operator found less-than second object to not be less-than", __LINE__);
165 testFramework.
assert( LessThanMicroSec < Compare ,
"Less-than operator found less-than microsecond object to not be less-than", __LINE__);
166 testFramework.
assert(!(Compare < LessThanSec),
"Less-than operator found greater-than second object to be less-than", __LINE__);
167 testFramework.
assert(!(Compare < LessThanMicroSec),
"Less-than operator found greater-than microsecond object to be less-than", __LINE__);
168 testFramework.
assert(!(Compare < CompareCopy),
"Less-than operator found equivalent object to be less-than", __LINE__);
175 testFramework.
assert(!(LessThanSec > Compare),
"Greater-than operator found less-than second object to not be greater-than", __LINE__);
176 testFramework.
assert(!(LessThanMicroSec > Compare),
"Greater-than operator found less-than microsecond object to not be greater-than", __LINE__);
177 testFramework.
assert( Compare > LessThanSec ,
"Greater-than operator found greater-than second object to be greater-than", __LINE__);
178 testFramework.
assert( Compare > LessThanMicroSec ,
"Greater-than operator found greater-than microsecond object to be greater-than", __LINE__);
179 testFramework.
assert(!(Compare > CompareCopy),
"Greater-than operator found equivalent object to be greater-than", __LINE__);
186 testFramework.
assert( LessThanSec <= Compare ,
"Less-than-or-equal-to operator found less-than second object to not be less-than-or-equal-to", __LINE__);
187 testFramework.
assert( LessThanMicroSec <= Compare ,
"Less-than-or-equal-to operator found less-than microsecond object to not be less-than-or-equal-to", __LINE__);
188 testFramework.
assert(!(Compare <= LessThanSec),
"Less-than-or-equal-to operator found greater-than second object to be less-than-or-equal-to", __LINE__);
189 testFramework.
assert(!(Compare <= LessThanMicroSec),
"Less-than-or-equal-to operator found greater-than microsecond object to be less-than-or-equal-to", __LINE__);
190 testFramework.
assert( Compare <= CompareCopy ,
"Less-than-or-equal-to operator found equivalent object to not be less-than-or-equal-to", __LINE__);
197 testFramework.
assert(!(LessThanSec >= Compare),
"Greater-than-or-equal-to operator found less-than second object to not be greater-than-or-equal-to", __LINE__);
198 testFramework.
assert(!(LessThanMicroSec >= Compare),
"Greater-than-or-equal-to operator found less-than microsecond object to not be greater-than-or-equal-to", __LINE__);
199 testFramework.
assert( Compare >= LessThanSec ,
"Greater-than-or-equal-to operator found greater-than second object to be greater-than-or-equal-to", __LINE__);
200 testFramework.
assert( Compare >= LessThanMicroSec ,
"Greater-than-or-equal-to operator found greater-than microsecond object to be greater-than-or-equal-to", __LINE__);
201 testFramework.
assert( Compare >= CompareCopy ,
"Greater-than-or-equal-to operator found equivalent object to not be greater-than-or-equal-to", __LINE__);
212 TestUtil testFramework(
"UnixTime",
"reset" , __FILE__, __LINE__ );
223 testFramework.
assert(0 == (
int)Compare.
tv.tv_sec,
"reset() did not set the second value to 0", __LINE__);
224 testFramework.
assert(0 == (
int)Compare.
tv.tv_usec,
"reset() did not set the microsecond value to 0", __LINE__);
235 TestUtil testFramework(
"UnixTime",
"isValid", __FILE__, __LINE__ );
250 testFramework.
assert(Compare.
isValid(),
"Time provided found to be unable to convert to/from CommonTime", __LINE__);
259 testFramework.
assert(Compare.
getTimeSystem()== Test2.
getTimeSystem(),
"TimeSystem provided found to be different after converting to and from CommonTime", __LINE__);
260 testFramework.
assert(Test2.
tv.tv_sec == Compare.
tv.tv_sec,
"Second provided found to be different after converting to and from CommonTime", __LINE__);
261 testFramework.
assert(Test2.
tv.tv_usec == Compare.
tv.tv_usec,
"Microsecond provided found to be different after converting to and from CommonTime", __LINE__);
272 TestUtil testFramework(
"UnixTime",
"OperatorEquivalentWithDifferingTimeSystem", __FILE__, __LINE__ );
286 testFramework.
assert(!(GPS1 == UTC1),
"Equivalence operator found objects with differing TimeSystems to be the same", __LINE__);
287 testFramework.
assert(GPS1 == ANY,
"Differing TimeSystems where one is TimeSystem::Any is not ignored for equals", __LINE__);
288 testFramework.
assert(UTC1 == ANY,
"Differing TimeSystems where one is TimeSystem::Any is not ignored for equals", __LINE__);
289 testFramework.
assert(UNKNOWN == ANY,
"Differing TimeSystems where one is TimeSystem::Any is not ignored for equals", __LINE__);
295 testFramework.
assert(GPS1 != UTC1,
"Equivalent objects with differing TimeSystems are found to be equal", __LINE__);
296 testFramework.
assert(GPS1 != UNKNOWN,
"Equivalent objects with differing TimeSystems are found to be equal", __LINE__);
297 testFramework.
assert(!(GPS1 != ANY),
"Equivalent objects with differing TimeSystems where one is TimeSystem::Any are found to be not-equal", __LINE__);
303 testFramework.
assert(ANY2 < GPS1,
"Less than object with Any TimeSystem is not found to be less than", __LINE__);
304 testFramework.
assert(GPS2 < ANY,
"Less than object with GPS TimeSystem is not found to be less-than a greater object with Any TimeSystem", __LINE__);
322 TestUtil testFramework(
"UnixTime",
"printf", __FILE__, __LINE__ );
331 testFramework.
assert(GPS1.
printf(
"%07U %02u %02P") == (std::string)
"1350000 00 GPS",
"printf did not output in the proper format", __LINE__);
332 testFramework.
assert(UTC1.
printf(
"%07U %02u %02P") == (std::string)
"1350000 00 UTC",
"printf did not output in the proper format", __LINE__);
338 testFramework.
assert(GPS1.
printError(
"%07U %02u %02P") == (std::string)
"ErrorBadTime ErrorBadTime ErrorBadTime",
"printError did not output in the proper format", __LINE__);
339 testFramework.
assert(UTC1.
printError(
"%07U %02u %02P") == (std::string)
"ErrorBadTime ErrorBadTime ErrorBadTime",
"printError did not output in the proper format", __LINE__);
347 int check, errorCounter = 0;
351 errorCounter += check;
354 errorCounter += check;
357 errorCounter += check;
360 errorCounter += check;
363 errorCounter += check;
366 errorCounter += check;
369 errorCounter += check;
371 std::cout <<
"Total Failures for " << __FILE__ <<
": " << errorCounter << std::endl;