44 #include "build_config.h"
59 int headerExceptionTest();
70 int dataExceptionTest();
96 std::string iPath = gnsstk::getPathData() + getFileSep();
97 std::string oPath = gnsstk::getPathTestTemp() + getFileSep();
99 dataRinexClockFile = iPath +
100 "test_input_rinex2_clock_RinexClockExample.96c";
105 dataRinexClockRef = iPath +
106 "test_input_rinex2_clock_RinexClockReference.96c";
107 dataBadEpochLine = iPath +
"test_input_rinex2_clock_BadEpochLine.96c";
108 dataIncompleteHeader = iPath +
109 "test_input_rinex2_clock_IncompleteHeader.96c";
110 dataInvalidLineLength = iPath +
111 "test_input_rinex2_clock_InvalidLineLength.96c";
112 dataNotAClockFile = iPath +
"test_input_rinex2_clock_NotAClockFile.96c";
113 dataUnknownHeaderLabel = iPath +
114 "test_input_rinex2_clock_UnknownHeaderLabel.96c";
116 dataTestOutput = oPath +
"test_output_rinex_clock_TestOutput.96o";
117 dataRoundTripOutput = oPath +
"test_output_rinex_clock_RoundTripOutput.96o";
134 TUDEF(
"RinexClockStream",
"operator<<" );
139 rinexClockFile( dataRinexClockFile.c_str() ),
140 ih( dataIncompleteHeader.c_str() ),
141 il( dataInvalidLineLength.c_str() ),
142 no( dataNotAClockFile.c_str() ),
143 uh( dataUnknownHeaderLabel.c_str() ),
144 out( dataTestOutput.c_str(), std::ios::out );
154 rinexClockFile >> rinexClockHeader;
160 out.exceptions( std::fstream::failbit );
164 out << rinexClockHeader;
169 TUFAIL(
"Exception while writing valid RINEX clock header");
175 TUFAIL(
"No Exception while writing invalid RINEX clock header");
185 TUFAIL(
"No Exception while writing invalid RINEX clock header");
195 TUFAIL(
"No Exception while writing invalid RINEX clock header");
212 TUFAIL(
"Exception while writing valid(ish) RINEX clock header");
215 while( rinexClockFile >> rinexClockData )
217 out << rinexClockData;
222 TUFAIL(
"Unanticipated exception caught");
225 return testFramework.countFails();
232 TUDEF(
"RinexClockData",
"operator>>" );
233 int numLinesSkip = 0;
237 rinexClockFile( dataRinexClockFile.c_str() ),
238 out( dataRoundTripOutput.c_str(), std::ios::out );
242 rinexClockFile.exceptions(std::fstream::failbit);
243 out.exceptions(std::fstream::failbit);
245 rinexClockFile >> rinexClockHeader;
246 out << rinexClockHeader;
248 while (rinexClockFile >> rinexClockData)
250 out << rinexClockData;
252 rinexClockFile.close();
255 testFramework.assert_files_equal(
256 __LINE__, dataRinexClockRef, dataRoundTripOutput,
257 "files do not match: " + dataRinexClockRef +
" " + dataRoundTripOutput,
258 numLinesSkip,
false,
true );
262 TUFAIL(
"Caught unanticipated exception");
265 return testFramework.countFails();
271 TUDEF(
"RinexClockStream",
"DataExceptions");
273 std::string msg_desc =
"";
274 std::string msg_expect =
", should throw gnsstk::Exception";
275 std::string msg_falsePass =
" but threw no exception.";
276 std::string msg_trueFail =
" but instead threw an unknown exception";
281 badEpochLine.exceptions(std::fstream::failbit);
284 msg_desc =
"BadEpochLine test";
287 while (badEpochLine >> cd);
288 TUFAIL(msg_desc + msg_expect + msg_falsePass);
292 TUPASS(msg_desc + msg_expect);
296 TUFAIL(msg_desc + msg_expect + msg_trueFail);
302 TUFAIL(
"Error thrown when running dataExceptionTest: "+e.
what());
306 TUFAIL(
"Unknown error thrown when running dataExceptionTest");
309 return testFramework.countFails();
322 std::cout <<
"Total Failures for " << __FILE__ <<
": " << errorTotal