58 gnsstk::TestUtil testFramework(
"GPSZcount",
"ConstructorExplicit2Inputs", __FILE__, __LINE__ );
68 testFramework.
assert(
true,
"Valid object constructed", __LINE__);
69 testFramework.
assert(validObject.
getWeek() == 10 ,
"Explicit constructor could not set week properly" , __LINE__);
70 testFramework.
assert(validObject.
getZcount() == 35,
"Explicit constructor could not set zcount properly", __LINE__);
71 testFramework.
assert(validObject.
getFullZcount() == 5242915 ,
"getFullZcount did not return the expected value" , __LINE__);
72 testFramework.
assert(validObject.
getTotalZcounts() == 4032035,
"getTotalZcount did not return the expected value", __LINE__);
74 catch(...){testFramework.
assert(
false,
"Valid object could not be constructed", __LINE__);}
80 testFramework.
assert(
false,
"Invalid week object could be constructed", __LINE__);
82 catch(gnsstk::InvalidParameter e){testFramework.
assert(
true,
"Expected exception caught", __LINE__);}
83 catch(...){testFramework.
assert(
false,
"Unexpected exception caught for creation of invalid week GPSZcount", __LINE__);}
89 testFramework.
assert(
false,
"Invalid zcount object could be constructed", __LINE__);
91 catch(gnsstk::InvalidParameter e){testFramework.
assert(
true,
"Expected exception caught", __LINE__);}
92 catch(...){testFramework.
assert(
false,
"Unexpected exception caught for creation of invalid zcount GPSZcount", __LINE__);}
99 testFramework.
assert(
false,
"Invalid zcount object could be constructed", __LINE__);
101 catch(gnsstk::InvalidParameter e){testFramework.
assert(
true,
"Expected exception caught", __LINE__);}
102 catch(...){testFramework.
assert(
false,
"Unexpected exception caught for creation of invalid zcount GPSZcount", __LINE__);}
114 int inputFullZcount = 1211600;
116 testFramework.
assert(
true,
"Valid object constructed", __LINE__);
117 testFramework.
assert(validObject.
getWeek() == 2 ,
"Explicit constructor could not set week properly" , __LINE__);
118 testFramework.
assert(validObject.
getZcount() == 163024,
"Explicit constructor could not set zcount properly", __LINE__);
119 testFramework.
assert(validObject.
getFullZcount() == 1211600 ,
"getFullZcount did not return the expected value" , __LINE__);
120 testFramework.
assert(validObject.
getTotalZcounts() == 969424,
"getTotalZcount did not return the expected value", __LINE__);
122 catch(...){testFramework.
assert(
false,
"Valid object could not be constructed", __LINE__);}
128 testFramework.
assert(
false,
"Invalid FullZCount object could be constructed", __LINE__);
130 catch(gnsstk::InvalidParameter e){testFramework.
assert(
true,
"Expected exception caught", __LINE__);}
131 catch(...){testFramework.
assert(
false,
"Unexpected exception caught for creation of invalid FullZCount GPSZcount", __LINE__);}
143 testFramework.
assert(
true,
"Valid object constructed", __LINE__);
144 testFramework.
assert(Copy.
getWeek() == 10 ,
"Copy constructor could not set week properly" , __LINE__);
145 testFramework.
assert(Copy.
getZcount() == 35,
"Copy constructor could not set zcount properly", __LINE__);
147 catch(...){testFramework.
assert(
false,
"Copy constructor could not copy a valid GPSZcount object", __LINE__);}
159 testFramework.
assert(
true,
"Valid object constructed", __LINE__);
160 testFramework.
assert(Copy.
getWeek() == 10 ,
"Set Operator could not set week properly" , __LINE__);
161 testFramework.
assert(Copy.
getZcount() == 35,
"Set Operator could not set zcount properly", __LINE__);
163 catch(...){testFramework.
assert(
false,
"Set Operator could not copy a valid GPSZcount object", __LINE__);}
176 testFramework.
assert(validObject.
getWeek() == 9 ,
"setWeek() did not set week properly" , __LINE__);
177 testFramework.
assert(validObject.
getZcount() == 1000,
"setZcount did not set zcount properly", __LINE__);
179 try{validObject.
setWeek(-100); testFramework.
assert(
false,
"setWeek allowed an invalid week to be set", __LINE__);}
180 catch(gnsstk::InvalidParameter e){testFramework.
assert(
true,
"Expected exception thrown", __LINE__);}
181 catch(...){testFramework.
assert(
false,
"Unexpected exception thrown", __LINE__);}
183 try{validObject.
setZcount(-100); testFramework.
assert(
false,
"setZcount allowed an invalid zcount to be set", __LINE__);}
184 catch(gnsstk::InvalidParameter e){testFramework.
assert(
true,
"Expected exception thrown", __LINE__);}
185 catch(...){testFramework.
assert(
false,
"Unexpected exception thrown", __LINE__);}
187 try{validObject.
setZcount(999999); testFramework.
assert(
false,
"setZcount allowed an invalid zcount to be set", __LINE__);}
188 catch(gnsstk::InvalidParameter e){testFramework.
assert(
true,
"Expected exception thrown", __LINE__);}
189 catch(...){testFramework.
assert(
false,
"Unexpected exception thrown", __LINE__);}
201 gnsstk::TestUtil testFramework(
"GPSZcount",
"addWeeks", __FILE__, __LINE__ );
209 testFramework.
assert(incWeek.
getWeek() == 12,
"addWeeks() did not set week properly" , __LINE__);
214 testFramework.
assert(decWeek.
getWeek() == 8,
"addWeeks() did not set week properly" , __LINE__);
221 testFramework.
assert(
false,
"addWeeks() allowed for change to an invalid week" , __LINE__);
223 catch(gnsstk::InvalidRequest e){testFramework.
assert(
true,
"Expected exception thrown", __LINE__);}
224 catch(...){testFramework.
assert(
false,
"Unexpected exception thrown", __LINE__);}
236 gnsstk::TestUtil testFramework(
"GPSZcount",
"addZcounts", __FILE__, __LINE__ );
243 testFramework.
assert(incZcount.
getZcount() == 37,
"addZcounts() did not set zcount properly" , __LINE__);
248 testFramework.
assert(decZcount.
getZcount() == 33,
"addZcounts() did not set zcount properly" , __LINE__);
253 testFramework.
assert(rollWeekF.
getWeek() == 11 ,
"addZcounts() did not roll week forward properly", __LINE__);
254 testFramework.
assert(rollWeekF.
getZcount() == 2,
"addZcounts() did not set zcount properly" , __LINE__);
259 testFramework.
assert(rollWeekB.
getWeek() == 9 ,
"addZcounts() did not roll week backward properly", __LINE__);
260 testFramework.
assert(rollWeekB.
getZcount() == 403198,
"addZcounts() did not set zcount properly" , __LINE__);
267 testFramework.
assert(
false,
"addZcounts() allowed for change to an invalid week" , __LINE__);
269 catch(gnsstk::InvalidRequest e){testFramework.
assert(
true,
"Expected exception thrown", __LINE__);}
270 catch(...){testFramework.
assert(
false,
"Unexpected exception thrown", __LINE__);}
282 gnsstk::TestUtil testFramework(
"GPSZcount",
"OperatorIncrement", __FILE__, __LINE__ );
287 testFramework.
assert(arbitraryObject.
getZcount() == 36,
"Postfix Increment operator did not set zcount properly" , __LINE__);
289 testFramework.
assert(arbitraryObject.
getZcount() == 37,
"Prefix Increment operator did not set zcount properly" , __LINE__);
294 testFramework.
assert(rollWeekF.
getWeek() == 11 ,
"Postfix Increment operator did not roll week forward properly", __LINE__);
295 testFramework.
assert(rollWeekF.
getZcount() == 0,
"Postfix Increment operator did not set zcount properly" , __LINE__);
300 testFramework.
assert(rollWeekF2.
getWeek() == 11 ,
"Postfix Increment operator did not roll week forward properly", __LINE__);
301 testFramework.
assert(rollWeekF2.
getZcount() == 0,
"Postfix Increment operator did not set zcount properly" , __LINE__);
312 gnsstk::TestUtil testFramework(
"GPSZcount",
"OperatorDecrement", __FILE__, __LINE__ );
317 testFramework.
assert(arbitraryObject.
getZcount() == 34,
"Postfix Decrement operator did not set zcount properly" , __LINE__);
319 testFramework.
assert(arbitraryObject.
getZcount() == 33,
"Prefix Decrement operator did not set zcount properly" , __LINE__);
324 testFramework.
assert(rollWeekB.
getWeek() == 9 ,
"Postfix Decrement operator did not roll week forward properly", __LINE__);
325 testFramework.
assert(rollWeekB.
getZcount() == 403199,
"Postfix Decrement operator did not set zcount properly" , __LINE__);
330 testFramework.
assert(rollWeekB2.
getWeek() == 9 ,
"Postfix Decrement operator did not roll week forward properly", __LINE__);
331 testFramework.
assert(rollWeekB2.
getZcount() == 403199,
"Postfix Decrement operator did not set zcount properly" , __LINE__);
343 gnsstk::TestUtil testFramework(
"GPSZcount",
"OperatorAddition", __FILE__, __LINE__ );
347 justAddition = justAddition + 35;
348 additionAssign += 4000;
350 testFramework.
assert(justAddition.
getZcount() == 70,
"Addition operator did not set zcount properly" , __LINE__);
351 testFramework.
assert(additionAssign.
getZcount() == 5000,
"Add and assign operator did not set zcount properly" , __LINE__);
356 justAdditionRollWeekF = justAdditionRollWeekF + 1000;
357 testFramework.
assert(justAdditionRollWeekF.
getWeek() == 11 ,
"Addition operator did not roll week forward properly", __LINE__);
358 testFramework.
assert(justAdditionRollWeekF.
getZcount() == 999,
"Addition operator did not set zcount properly" , __LINE__);
361 additionAssignRollWeekF += 2000;
362 testFramework.
assert(additionAssignRollWeekF.
getWeek() == 5 ,
"Add and assign operator did not roll week forward properly", __LINE__);
363 testFramework.
assert(additionAssignRollWeekF.
getZcount() == 1999,
"Add and assign operator did not set zcount properly" , __LINE__);
375 gnsstk::TestUtil testFramework(
"GPSZcount",
"OperatorSubtraction", __FILE__, __LINE__ );
379 justSubtraction = justSubtraction - 15;
380 subtractionAssign -= 500;
382 testFramework.
assert(justSubtraction.
getZcount() == 20,
"Subtraction operator did not set zcount properly" , __LINE__);
383 testFramework.
assert(subtractionAssign.
getZcount() == 500,
"Subtract and assign operator did not set zcount properly" , __LINE__);
387 justSubtractionRollWeekB = justSubtractionRollWeekB - 100;
388 testFramework.
assert(justSubtractionRollWeekB.
getWeek() == 9 ,
"Subtraction operator did not roll week forward properly", __LINE__);
389 testFramework.
assert(justSubtractionRollWeekB.
getZcount() == 403100,
"Subtraction operator did not set zcount properly" , __LINE__);
393 subtractionAssignRollWeekB -= 200;
394 testFramework.
assert(subtractionAssignRollWeekB.
getWeek() == 1 ,
"Subtract and assign operator did not roll week forward properly", __LINE__);
395 testFramework.
assert(subtractionAssignRollWeekB.
getZcount() == 403000,
"Subtract and assign operator did not set zcount properly" , __LINE__);
409 gnsstk::TestUtil testFramework(
"GPSZcount",
"OperatorDifference", __FILE__, __LINE__ );
412 double diffLessThan, diffMoreThan, diffSame;
419 diffLessThan =
object - lessThanObject;
420 diffMoreThan =
object - moreThanObject;
421 diffSame =
object - objectCopy;
423 testFramework.
assert(diffLessThan == 2419222,
"Difference operator did not obtain the correct result" , __LINE__);
424 testFramework.
assert(diffMoreThan == -2016965,
"Difference operator did not obtain the correct result" , __LINE__);
425 testFramework.
assert(diffSame == 0,
"Difference operator did not obtain the correct result" , __LINE__);
437 gnsstk::TestUtil testFramework(
"GPSZcount",
"OperatorRemainder", __FILE__, __LINE__ );
440 long remaiderWeek, remainderValue;
444 remaiderWeek =
object % 403200;
445 remainderValue =
object % 25;
447 testFramework.
assert(remaiderWeek == 25,
"Remainder operator did not obtain the correct result" , __LINE__);
448 testFramework.
assert(remainderValue == 0,
"Remainder operator did not obtain the correct result" , __LINE__);
460 gnsstk::TestUtil testFramework(
"GPSZcount",
"OperatorEquivalence", __FILE__, __LINE__ );
470 testFramework.
assert( Compare == CompareCopy,
"Equivalence operator found equivalent objects to be not equivalent", __LINE__);
471 testFramework.
assert(!(Compare == LessThanWeek),
"Equivalence operator found different week objects to be equivalent", __LINE__);
472 testFramework.
assert(!(Compare == LessThanZcount),
"Equivalence operator found different zcount objects to be equivalent", __LINE__);
479 testFramework.
assert( Compare != LessThanWeek,
"Not-equal operator found different week objects to be equivalent", __LINE__);
480 testFramework.
assert( Compare != LessThanZcount,
"Not-equal operator found different zcount objects to be equivalent", __LINE__);
481 testFramework.
assert(!(Compare != Compare),
"Not-equal operator found equivalent objects to not be equivalent", __LINE__);
488 testFramework.
assert( LessThanWeek < Compare,
"Less-than operator found less-than week object to not be less than", __LINE__);
489 testFramework.
assert( LessThanZcount < Compare,
"Less-than operator found less-than zcount object to not be less than", __LINE__);
490 testFramework.
assert(!(Compare < LessThanWeek),
"Less-than operator found greater-than week object to be less than", __LINE__);
491 testFramework.
assert(!(Compare < LessThanZcount),
"Less-than operator found greater-than zcount object to be less than", __LINE__);
492 testFramework.
assert(!(Compare < CompareCopy),
"Less-than operator found equivalent object to be less than", __LINE__);
498 testFramework.
assert(!(LessThanWeek > Compare),
"Greater-than operator found less-than week object to be greater than", __LINE__);
499 testFramework.
assert(!(LessThanZcount > Compare),
"Greater-than operator found less-than zcount object to be greater than", __LINE__);
500 testFramework.
assert( Compare > LessThanWeek,
"Greater-than operator found greater-than week object to not be greater than", __LINE__);
501 testFramework.
assert( Compare > LessThanZcount,
"Greater-than operator found greater-than zcount object to not be greater than", __LINE__);
502 testFramework.
assert(!(Compare > CompareCopy),
"Greater-than operator found equivalent object to be greater than", __LINE__);
509 testFramework.
assert( LessThanWeek <= Compare,
"Less-than operator found less-than week object to not be less-than-or-equal-to", __LINE__);
510 testFramework.
assert( LessThanZcount <= Compare,
"Less-than operator found less-than zcount object to not be less-than-or-equal-to", __LINE__);
511 testFramework.
assert(!(Compare <= LessThanWeek),
"Less-than operator found greater-than week object to be less-than-or-equal-to", __LINE__);
512 testFramework.
assert(!(Compare <= LessThanZcount),
"Less-than operator found greater-than zcount object to be less-than-or-equal-to", __LINE__);
513 testFramework.
assert( Compare <= CompareCopy,
"Less-than operator found equivalent object to not be less-than-or-equal-to", __LINE__);
520 testFramework.
assert(!(LessThanWeek >= Compare),
"Greater-than-or-equal-to operator found less-than week object to be greater-than-or-equal-to", __LINE__);
521 testFramework.
assert(!(LessThanZcount >= Compare),
"Greater-than-or-equal-to operator found less-than zcount object to be greater-than-or-equal-to", __LINE__);
522 testFramework.
assert( Compare >= LessThanWeek,
"Greater-than-or-equal-to operator found greater-than week object to not be greater-than-or-equal-to", __LINE__);
523 testFramework.
assert( Compare >= LessThanZcount,
"Greater-than-or-equal-to operator found greater-than zcount object to not be greater-than-or-equal-to", __LINE__);
524 testFramework.
assert( Compare >= CompareCopy,
"Greater-than-or-equal-to operator found equivalent object to not be greater-than-or-equal-to", __LINE__);
536 gnsstk::TestUtil testFramework(
"GPSZcount",
"OperatorString", __FILE__, __LINE__ );
538 std::string expectedResult =
"1234w56789z";
540 std::string obtainedResult = std::string(
object);
542 testFramework.
assert(obtainedResult == expectedResult,
"string operator did not obtain the expected result", __LINE__);
555 std::stringstream obtainedOutputStreamLevel0;
556 std::stringstream obtainedOutputStreamLevel1;
557 std::stringstream expectedOutputStreamLevel0;
558 std::stringstream expectedOutputStreamLevel1;
560 expectedOutputStreamLevel0 <<
"1234w56789z";
561 expectedOutputStreamLevel1 <<
"GPS Full Week: " << std::setw(6) << 1234 << std::endl
562 <<
"GPS Z-count: " << std::setw(6) << 56789 << std::endl;
565 object.dump(obtainedOutputStreamLevel0, 0);
566 object.dump(obtainedOutputStreamLevel1, 1);
569 std::string testMessage =
" did not obtain the expected result";
570 testFramework.
assert(obtainedOutputStreamLevel0.str() == expectedOutputStreamLevel0.str(),
"dump did not obtain the expected result", __LINE__);
571 testFramework.
assert(obtainedOutputStreamLevel1.str() == expectedOutputStreamLevel1.str(),
"dump did not obtain the expected result", __LINE__);
582 gnsstk::TestUtil testFramework(
"GPSZcount",
"inSameTimeBlock", __FILE__, __LINE__ );
611 testFramework.
assert(isWithinMinute ,
"Returned false when object difference is 20 and timeblock is 40" , __LINE__);
612 testFramework.
assert(isNotWithinMinute ,
"Returned true when object difference is 1000 and timeblock is 40" , __LINE__);
613 testFramework.
assert(isWithinWeek ,
"Returned false when object difference is 1000 and timeblock is 403200" , __LINE__);
614 testFramework.
assert(!isAtWeek ,
"Returned true when object difference is 403200 and timeblock is 403200" , __LINE__);
615 testFramework.
assert(isNearWeek ,
"Returned false when object difference is 403199 and timeblock is 403200" , __LINE__);
616 testFramework.
assert(isNotWithinWeek ,
"Returned true when object difference is 403210 and timeblock is 403200" , __LINE__);
617 testFramework.
assert(isWithin3Weeks ,
"Returned false when object difference is 806400 and timeblock is 1209600" , __LINE__);
618 testFramework.
assert(isWithinMinuteOffset,
"Returned false when object difference is 30 and shifted timeblock is 40" , __LINE__);
619 testFramework.
assert(isWithinWeekOffset ,
"Returned false when object difference is 403190 and shifted timeblock is 403200", __LINE__);
630 int check, errorCounter = 0;
634 errorCounter += check;
637 errorCounter += check;
640 errorCounter += check;
643 errorCounter += check;
646 errorCounter += check;
649 errorCounter += check;
652 errorCounter += check;
655 errorCounter += check;
658 errorCounter += check;
661 errorCounter += check;
664 errorCounter += check;
666 std::cout <<
"Total Failures for " << __FILE__ <<
": " << errorCounter << std::endl;