101 bool readNums(
const string& filename);
110 void dumpBuffer(
const unsigned char* buffer,
size_t size);
135 +
"test_input_binex_readwrite.txt";
137 if (verboseLevel > 0)
139 cout <<
" Reading test input . . ." << endl;
143 if (verboseLevel > 0)
145 cout <<
" " << numList.size() <<
" numbers" << endl;
146 cout <<
" Creating BINEX records . . ." << endl;
149 if (verboseLevel > 0)
151 cout <<
" " << testRecords.size() <<
" records" << endl;
186 ifstream ifs(filename.c_str());
197 string::size_type hashPos = line.find(
'#');
198 if (hashPos != string::npos)
203 string::size_type nonWhitePos = line.find_first_not_of(
" \t");
204 if (nonWhitePos != string::npos)
206 istringstream iss(line);
212 if (charToType(c, num.
dtype))
215 numList.push_back(num);
219 if (verboseLevel > 0)
221 cout <<
" Warning: Unrecognized data type: " << c << endl;
226 return (numList.size() > 0);
232 TestDataList::const_iterator tdIter = numList.begin();
233 while (tdIter != numList.end() )
241 for ( ; (dataNum < 9) && (tdIter != numList.end()); ++dataNum, ++tdIter)
243 switch (tdIter->dtype)
247 char c = tdIter->value;
253 short s = tdIter->value;
259 long l = tdIter->value;
277 cout <<
" Internal error during record creation" << std::endl;
280 recordData.push_back(*tdIter);
282 testData.push_back(recordData);
283 testRecords.push_back(record);
291 TUDEF(
"BinexData",
"Read/Write (Fwd)");
294 string tempFileName =
tempFilePath + gnsstk::getFileSep() +
295 "test_output_binex_readwrite.binex";
297 std::ios::out | std::ios::binary);
301 outStream.exceptions(ios_base::failbit | ios_base::badbit);
302 RecordList::iterator recordIter = testRecords.begin();
303 for ( ; recordIter != testRecords.end(); ++recordIter)
307 std::streampos posBefore = outStream.tellp();
308 (*recordIter).putRecord(outStream);
309 std::streampos posAfter = outStream.tellp();
310 TUASSERTE(
long long, (*recordIter).getRecordSize(), (posAfter - posBefore));
315 oss <<
"exception writing record: " << e;
320 TUFAIL(
"unknown exception writing record");
326 std::ios::in | std::ios::binary);
327 inStream.exceptions(ios_base::failbit);
331 recordIter = testRecords.begin();
332 while (inStream.good() && (EOF != inStream.peek() ) )
334 if (recordIter == testRecords.end() )
336 TUFAIL(
"stored records exhausted before file records");
343 if (record == *recordIter)
345 TUPASS(
"gotten record matches");
350 oss <<
"Actual record:" << endl;
351 (*recordIter).dump(oss);
352 oss <<
"Expected record:" << endl;
361 oss <<
"stream exception reading record: " << e;
366 TUFAIL(
"unknown exception reading record");
379 TUDEF(
"BinexData",
"Read/Write (Rev)");
391 int main(
int argc,
char *argv[])
401 return( errorTotal );