62 TestUtil testFramework(
"CivilTime",
"Constructor", __FILE__, __LINE__ );
69 testFramework.
assert(2008 == (
int)Compare.
year,
"Explicit constructor did not set the year properly", __LINE__);
70 testFramework.
assert( 8 == (
int)Compare.
month,
"Explicit constructor did not set the month properly", __LINE__);
71 testFramework.
assert(21 == (
int)Compare.
day,
"Explicit constructor did not set the day properly", __LINE__);
72 testFramework.
assert(13 == (
int)Compare.
hour,
"Explicit constructor did not set the hour properly", __LINE__);
73 testFramework.
assert(30 == (
int)Compare.
minute,
"Explicit constructor did not set the minute properly", __LINE__);
74 testFramework.
assert(15 == (
double)Compare.
second,
"Explicit constructor did not set the second properly", __LINE__);
83 testFramework.
assert(2008 == (
int)Copy.
year,
"Copy constructor did not set the year properly", __LINE__);
84 testFramework.
assert(8 == (
int)Copy.
month,
"Copy constructor did not set the month properly", __LINE__);
85 testFramework.
assert(21 == (
int)Copy.
day,
"Copy constructor did not set the day properly", __LINE__);
86 testFramework.
assert(13 == (
int)Copy.
hour,
"Copy constructor did not set the hour properly", __LINE__);
87 testFramework.
assert(30 == (
int)Copy.
minute,
"Copy constructor did not set the minute properly", __LINE__);
88 testFramework.
assert(15 == (
double)Copy.
second,
"Copy constructor did not set the second properly", __LINE__);
98 testFramework.
assert(2008 == (
int)Assigned.
year,
"Set Operator did not set the year properly", __LINE__);
99 testFramework.
assert(8 == (
int)Assigned.
month,
"Set Operator did not set the month properly", __LINE__);
100 testFramework.
assert(21 == (
int)Assigned.
day,
"Set Operator did not set the day properly", __LINE__);
101 testFramework.
assert(13 == (
int)Assigned.
hour,
"Set Operator did not set the hour properly", __LINE__);
102 testFramework.
assert(30 == (
int)Assigned.
minute,
"Set Operator did not set the mimute properly", __LINE__);
103 testFramework.
assert(15 == (
double)Assigned.
second,
"Set Operator did not set the second properly", __LINE__);
113 TestUtil testFramework(
"CivilTime",
"setFromInfo", __FILE__, __LINE__ );
135 testFramework.
assert(setFromInfo1.
setFromInfo(Id),
"setFromInfo experienced an error and returned false", __LINE__);
136 testFramework.
assert(setFromInfo1 == Check,
"setFromInfo did not set all of the values properly", __LINE__);
147 testFramework.
assert(setFromInfo2.
setFromInfo(Id),
"setFromInfo experienced an error and returned false", __LINE__);
148 testFramework.
assert(setFromInfo2 == Check2,
"setFromInfo did not set all of the values properly", __LINE__);
156 testFramework.
assert(!setFromInfo3.
setFromInfo(Id),
"setFromInfo allowed a 3 digit year to be set with 'y' option", __LINE__);
163 testFramework.
assert(setFromInfo4.
setFromInfo(Id),
"setFromInfo experienced an error and returned false", __LINE__);
171 testFramework.
assert(!(setFromInfo5.
setFromInfo(Id)),
"setFromInfo allowed the month to be set with an improper value", __LINE__);
184 TestUtil testFramework(
"CivilTime",
"OperatorEquivalent", __FILE__, __LINE__ );
188 CivilTime LessThanYear(2005,8,21,13,30,15.);
189 CivilTime LessThanMonth(2008,7,21,13,30,15.);
190 CivilTime LessThanDay(2008,8,20,13,30,15.);
191 CivilTime LessThanHour(2008,8,21,12,30,15.);
192 CivilTime LessThanMinute(2008,8,21,13,20,15.);
193 CivilTime LessThanSecond(2008,8,21,13,30,0.);
200 testFramework.
assert( Aug21 == Aug21Copy,
"Equivalence operator found equivalent objects to be not equivalent", __LINE__);
201 testFramework.
assert(!(Aug21 == LessThanYear),
"Equivalence operator found different year objects to be equivalent", __LINE__);
202 testFramework.
assert(!(Aug21 == LessThanMonth),
"Equivalence operator found different month objects to be equivalent", __LINE__);
203 testFramework.
assert(!(Aug21 == LessThanDay),
"Equivalence operator found different day objects to be equivalent", __LINE__);
204 testFramework.
assert(!(Aug21 == LessThanHour),
"Equivalence operator found different hour objects to be equivalent", __LINE__);
205 testFramework.
assert(!(Aug21 == LessThanMinute),
"Equivalence operator found different minute objects to be equivalent", __LINE__);
206 testFramework.
assert(!(Aug21 == LessThanSecond),
"Equivalence operator found different second objects to be equivalent", __LINE__);
213 testFramework.
assert( Aug21 != LessThanYear,
"Not-equal operator found different year objects to be equivalent", __LINE__);
214 testFramework.
assert( Aug21 != LessThanMonth,
"Not-equal operator found different month objects to be equivalent", __LINE__);
215 testFramework.
assert( Aug21 != LessThanDay,
"Not-equal operator found different day objects to be equivalent", __LINE__);
216 testFramework.
assert( Aug21 != LessThanHour,
"Not-equal operator found different hour objects to be equivalent", __LINE__);
217 testFramework.
assert( Aug21 != LessThanMinute,
"Not-equal operator found different minute objects to be equivalent", __LINE__);
218 testFramework.
assert( Aug21 != LessThanSecond,
"Not-equal operator found different second objects to be equivalent", __LINE__);
219 testFramework.
assert(!(Aug21 != Aug21Copy),
"Not-equal operator found equivalent objects to not be equivalent", __LINE__);
225 testFramework.
assert( LessThanYear < Aug21,
"Less-than operator found less-than year object to not be less than", __LINE__);
226 testFramework.
assert( LessThanMonth < Aug21,
"Less-than operator found less-than month object to not be less than", __LINE__);
227 testFramework.
assert( LessThanDay < Aug21,
"Less-than operator found less-than day object to not be less than", __LINE__);
228 testFramework.
assert( LessThanHour < Aug21,
"Less-than operator found less-than hour object to not be less than", __LINE__);
229 testFramework.
assert( LessThanMinute < Aug21,
"Less-than operator found less-than minute object to not be less than", __LINE__);
230 testFramework.
assert( LessThanSecond < Aug21,
"Less-than operator found less-than second object to not be less than", __LINE__);
231 testFramework.
assert(!(Aug21 < LessThanYear),
"Less-than operator found greater-than year object to be less than", __LINE__);
232 testFramework.
assert(!(Aug21 < LessThanMonth),
"Less-than operator found greater-than month object to be less than", __LINE__);
233 testFramework.
assert(!(Aug21 < LessThanDay),
"Less-than operator found greater-than day object to be less than", __LINE__);
234 testFramework.
assert(!(Aug21 < LessThanHour),
"Less-than operator found greater-than hour object to be less than", __LINE__);
235 testFramework.
assert(!(Aug21 < LessThanMinute),
"Less-than operator found greater-than minute object to be less than", __LINE__);
236 testFramework.
assert(!(Aug21 < LessThanSecond),
"Less-than operator found greater-than second object to be less than", __LINE__);
237 testFramework.
assert(!(Aug21 < Aug21Copy),
"Less-than operator found equivalent objects to be less than", __LINE__);
244 testFramework.
assert(!(LessThanYear > Aug21),
"Greater-than operator found less-than year object to be greater-than", __LINE__);
245 testFramework.
assert(!(LessThanMonth > Aug21),
"Greater-than operator found less-than month object to be greater-than", __LINE__);
246 testFramework.
assert(!(LessThanDay > Aug21),
"Greater-than operator found less-than day object to be greater-than", __LINE__);
247 testFramework.
assert(!(LessThanHour > Aug21),
"Greater-than operator found less-than hour object to be greater-than", __LINE__);
248 testFramework.
assert(!(LessThanMinute > Aug21),
"Greater-than operator found less-than minute object to be greater-than", __LINE__);
249 testFramework.
assert(!(LessThanSecond > Aug21),
"Greater-than operator found less-than second object to be greater-than", __LINE__);
250 testFramework.
assert( Aug21 > LessThanYear,
"Greater-than operator found greater-than year object to not be greater-than", __LINE__);
251 testFramework.
assert( Aug21 > LessThanMonth,
"Greater-than operator found greater-than month object to not be greater-than", __LINE__);
252 testFramework.
assert( Aug21 > LessThanDay,
"Greater-than operator found greater-than day object to not be greater-than", __LINE__);
253 testFramework.
assert( Aug21 > LessThanHour,
"Greater-than operator found greater-than hour object to not be greater-than", __LINE__);
254 testFramework.
assert( Aug21 > LessThanMinute,
"Greater-than operator found greater-than minute object to not be greater-than", __LINE__);
255 testFramework.
assert( Aug21 > LessThanSecond,
"Greater-than operator found greater-than second object to not be greater-than", __LINE__);
256 testFramework.
assert(!(Aug21 > Aug21Copy),
"Greater-than operator found equivalent objects to be greater-than", __LINE__);
263 testFramework.
assert( LessThanYear <= Aug21,
"Less-than-or-equal-to operator found less-than year object to not be less-than-or-equal-to", __LINE__);
264 testFramework.
assert( LessThanMonth <= Aug21,
"Less-than-or-equal-to operator found less-than month object to not be less-than-or-equal-to", __LINE__);
265 testFramework.
assert( LessThanDay <= Aug21,
"Less-than-or-equal-to operator found less-than day object to not be less-than-or-equal-to", __LINE__);
266 testFramework.
assert( LessThanHour <= Aug21,
"Less-than-or-equal-to operator found less-than hour object to not be less-than-or-equal-to", __LINE__);
267 testFramework.
assert( LessThanMinute <= Aug21,
"Less-than-or-equal-to operator found less-than minute object to not be less-than-or-equal-to", __LINE__);
268 testFramework.
assert( LessThanSecond <= Aug21,
"Less-than-or-equal-to operator found less-than second object to not be less-than-or-equal-to", __LINE__);
269 testFramework.
assert(!(Aug21 <= LessThanYear),
"Less-than-or-equal-to operator found greater-than year object to be less-than-or-equal-to", __LINE__);
270 testFramework.
assert(!(Aug21 <= LessThanMonth),
"Less-than-or-equal-to operator found greater-than month object to be less-than-or-equal-to", __LINE__);
271 testFramework.
assert(!(Aug21 <= LessThanDay),
"Less-than-or-equal-to operator found greater-than day object to be less-than-or-equal-to", __LINE__);
272 testFramework.
assert(!(Aug21 <= LessThanHour),
"Less-than-or-equal-to operator found greater-than hour object to be less-than-or-equal-to", __LINE__);
273 testFramework.
assert(!(Aug21 <= LessThanMinute),
"Less-than-or-equal-to operator found greater-than minute object to be less-than-or-equal-to", __LINE__);
274 testFramework.
assert(!(Aug21 <= LessThanSecond),
"Less-than-or-equal-to operator found greater-than second object to be less-than-or-equal-to", __LINE__);
275 testFramework.
assert( Aug21 <= Aug21Copy,
"Less-than-or-equal-to operator found equivalent objects to not be less-than-or-equal-to", __LINE__);
282 testFramework.
assert(!(LessThanYear >= Aug21),
"Greater-than-or-equal-to operator found less-than year object to be greater-than-or-equal-to", __LINE__);
283 testFramework.
assert(!(LessThanMonth >= Aug21),
"Greater-than-or-equal-to operator found less-than month object to be greater-than-or-equal-to", __LINE__);
284 testFramework.
assert(!(LessThanDay >= Aug21),
"Greater-than-or-equal-to operator found less-than day object to be greater-than-or-equal-to", __LINE__);
285 testFramework.
assert(!(LessThanHour >= Aug21),
"Greater-than-or-equal-to operator found less-than hour object to be greater-than-or-equal-to", __LINE__);
286 testFramework.
assert(!(LessThanMinute >= Aug21),
"Greater-than-or-equal-to operator found less-than minute object to be greater-than-or-equal-to", __LINE__);
287 testFramework.
assert(!(LessThanSecond >= Aug21),
"Greater-than-or-equal-to operator found less-than second object to be greater-than-or-equal-to", __LINE__);
288 testFramework.
assert( Aug21 >= LessThanYear,
"Greater-than-or-equal-to operator found greater-than year object to not be greater-than-or-equal-to", __LINE__);
289 testFramework.
assert( Aug21 >= LessThanMonth,
"Greater-than-or-equal-to operator found greater-than month object to not be greater-than-or-equal-to", __LINE__);
290 testFramework.
assert( Aug21 >= LessThanDay,
"Greater-than-or-equal-to operator found greater-than day object to not be greater-than-or-equal-to", __LINE__);
291 testFramework.
assert( Aug21 >= LessThanHour,
"Greater-than-or-equal-to operator found greater-than hour object to not be greater-than-or-equal-to", __LINE__);
292 testFramework.
assert( Aug21 >= LessThanMinute,
"Greater-than-or-equal-to operator found greater-than minute object to not be greater-than-or-equal-to", __LINE__);
293 testFramework.
assert( Aug21 >= LessThanSecond,
"Greater-than-or-equal-to operator found greater-than second object to not be greater-than-or-equal-to", __LINE__);
294 testFramework.
assert( Aug21 >= Aug21Copy,
"Greater-than-or-equal-to operator found equivalent objects to not be greater-than-or-equal-to", __LINE__);
306 TestUtil testFramework(
"CivilTime",
"isValid", __FILE__, __LINE__ );
317 testFramework.
assert(Aug21.
isValid(),
"Time provided found to be unable to convert to/from CommonTime", __LINE__);
329 testFramework.
assert(Test2.
getTimeSystem()==Aug21.
getTimeSystem(),
"TimeSystem provided found to be different after converting to and from CommonTime", __LINE__);
330 testFramework.
assert(Test2.
year == Aug21.
year,
"Year provided found to be different after converting to and from CommonTime", __LINE__);
331 testFramework.
assert(Test2.
month == Aug21.
month,
"Month provided found to be different after converting to and from CommonTime", __LINE__);
332 testFramework.
assert(Test2.
day == Aug21.
day,
"Day provided found to be different after converting to and from CommonTime", __LINE__);
333 testFramework.
assert(Test2.
hour == Aug21.
hour,
"Hour provided found to be different after converting to and from CommonTime", __LINE__);
334 testFramework.
assert(Test2.
minute == Aug21.
minute,
"Minute provided found to be different after converting to and from CommonTime", __LINE__);
335 testFramework.
assert(Test2.
second == Aug21.
second,
"Second provided found to be different after converting to and from CommonTime", __LINE__);
349 TestUtil testFramework(
"CivilTime",
"reset", __FILE__, __LINE__ );
358 testFramework.
assert(0 == (
int)Aug21.
year,
"Year not set to default (0) after reset", __LINE__);
359 testFramework.
assert(1 == (
int)Aug21.
month,
"Month not set to default (1) after reset", __LINE__);
360 testFramework.
assert(1 == (
int)Aug21.
day,
"Day not set to default (1) after reset", __LINE__);
361 testFramework.
assert(0 == (
int)Aug21.
hour,
"Hour not set to default (0) after reset", __LINE__);
362 testFramework.
assert(0 == (
int)Aug21.
minute,
"Minute not set to default (0) after reset", __LINE__);
363 testFramework.
assert(0 == (
int)Aug21.
second,
"Second not set to default (0) after reset", __LINE__);
374 TestUtil testFramework(
"CivilTime",
"OperatorEquivalentWithDifferingTimeSystem", __FILE__, __LINE__ );
387 testFramework.
assert(!(GPS1 == UTC1),
"Equivalence operator found objects with differing TimeSystems to be the same", __LINE__);
388 testFramework.
assert(GPS1 == ANY,
"Differing TimeSystems where one is TimeSystem::Any is not ignored for equals", __LINE__);
389 testFramework.
assert(UTC1 == ANY,
"Differing TimeSystems where one is TimeSystem::Any is not ignored for equals", __LINE__);
390 testFramework.
assert(UNKNOWN == ANY,
"Differing TimeSystems where one is TimeSystem::Any is not ignored for equals", __LINE__);
396 testFramework.
assert(GPS1 != UTC1,
"Equivalent objects with differing TimeSystems are found to be equal", __LINE__);
397 testFramework.
assert(GPS1 != UNKNOWN,
"Equivalent objects with differing TimeSystems are found to be equal", __LINE__);
398 testFramework.
assert(!(GPS1 != ANY),
"Equivalent objects with differing TimeSystems where one is TimeSystem::Any are found to be not-equal", __LINE__);
404 testFramework.
assert(ANY2 < GPS1,
"Less than object with Any TimeSystem is not found to be less than", __LINE__);
405 testFramework.
assert(GPS2 < ANY,
"Less than object with GPS TimeSystem is not found to be less-than a greater object with Any TimeSystem", __LINE__);
425 TestUtil testFramework(
"CivilTime",
"printf", __FILE__, __LINE__ );
432 testFramework.
assert(GPS1.
printf(
"%04Y %02y %02m %02b %02d %02H %02M %02S %02f %02P") ==
433 (std::string)
"2008 08 08 Aug 21 13 30 15 15.000000 GPS",
"printf did not output in the proper format", __LINE__);
434 testFramework.
assert(UTC1.
printf(
"%04Y %02y %02m %02b %02d %02H %02M %02S %02f %02P") ==
435 (std::string)
"2008 08 08 Aug 21 13 30 15 15.000000 UTC",
"printf did not output in the proper format", __LINE__);
442 testFramework.
assert(GPS1.
printError(
"%04Y %02y %02m %02b %02d %02H %02M %02S %02f %02P") ==
443 (std::string)
"ErrorBadTime ErrorBadTime ErrorBadTime ErrorBadTime ErrorBadTime ErrorBadTime ErrorBadTime ErrorBadTime ErrorBadTime ErrorBadTime",
"printError did not output in the proper format", __LINE__);
444 testFramework.
assert(UTC1.
printError(
"%04Y %02y %02m %02b %02d %02H %02M %02S %02f %02P") ==
445 (std::string)
"ErrorBadTime ErrorBadTime ErrorBadTime ErrorBadTime ErrorBadTime ErrorBadTime ErrorBadTime ErrorBadTime ErrorBadTime ErrorBadTime",
"printError did not output in the proper format", __LINE__);
457 int check, errorCounter = 0;
461 errorCounter += check;
464 errorCounter += check;
467 errorCounter += check;
470 errorCounter += check;
473 errorCounter += check;
476 errorCounter += check;
479 errorCounter += check;
481 std::cout <<
"Total Errors: " << errorCounter << std::endl;