RinexMet_T.cpp
Go to the documentation of this file.
1 //==============================================================================
2 //
3 // This file is part of GNSSTk, the ARL:UT GNSS Toolkit.
4 //
5 // The GNSSTk is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published
7 // by the Free Software Foundation; either version 3.0 of the License, or
8 // any later version.
9 //
10 // The GNSSTk is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with GNSSTk; if not, write to the Free Software Foundation,
17 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
18 //
19 // This software was developed by Applied Research Laboratories at the
20 // University of Texas at Austin.
21 // Copyright 2004-2022, The Board of Regents of The University of Texas System
22 //
23 //==============================================================================
24 
25 //==============================================================================
26 //
27 // This software was developed by Applied Research Laboratories at the
28 // University of Texas at Austin, under contract to an agency or agencies
29 // within the U.S. Department of Defense. The U.S. Government retains all
30 // rights to use, duplicate, distribute, disclose, or release this software.
31 //
32 // Pursuant to DoD Directive 523024
33 //
34 // DISTRIBUTION STATEMENT A: This software has been approved for public
35 // release, distribution is unlimited.
36 //
37 //==============================================================================
38 
39 #include "RinexMetBase.hpp"
40 #include "RinexMetData.hpp"
41 #include "RinexMetHeader.hpp"
43 #include "RinexMetStream.hpp"
44 
45 #include "StringUtils.hpp"
46 #include "Exception.hpp"
47 
48 #include "build_config.h"
49 
50 #include "TestUtil.hpp"
51 #include <fstream>
52 #include <string>
53 #include <iostream>
54 
55 using namespace gnsstk;
56 using namespace std;
57 
58 
59 //============================================================
60 // Test Class Declarations
61 //============================================================
62 
63 
64 //------------------------------------------------------------
65 // Class: RinexMet_T
66 // Purpose: This test covers the RinexMet*
67 // files for Rinex I/O Manipulation
68 //------------------------------------------------------------
70 {
71 
72 public:
73 
75  {
76  init();
77  }
78 
80 
81  void init();
82 
83  int openMissingFileTest();
84  int bitsAsStringTest();
85  int bitStringTest();
86  int reallyPutRecordTest();
87  int reallyGetRecordTest();
88  int convertObsTypeSTRTest();
89  int convertObsTypeHeaderTest();
90  int hardCodeTest();
91  int continuationTest();
92  int dataExceptionsTest();
93  int filterOperatorsTest();
94  int versionTest();
95 
96 private:
97 
98  // for version controled files needed for testing
99  std::string dataFilePath;
100 
101  // for temporary ntermediate and output files
102  // used during testing but not to be version controlled
103  std::string tempFilePath;
104 
105  //----------------------------------------
106  // Input File descriptions
107  //----------------------------------------
108  // Normal = Normal Met File (No changes, straight from the archive)
109  // BLL = Bad Line Length Met file (Add a space characacter to the end of the first line)
110  // NMF = Not a Met File (Change Met to zet in first line)
111  // BOL = Bad Obs line (Add in something between the MET obs besides space)
112  // FER = Bad Sesor Type line, Format Error
113  // ExtraH = Extra header line with HEADERLINE2
114  // UnSup = Unsupported Rinex Version (3.30)
115  // MissingSPos = Missing SensorPos
116  // ObsHStrErr = Error in the part of the header which holds the list of observations within the Met file
117  // SensorType = Error in the sensor type
118  //----------------------------------------
119 
120  std::string inputNormal;
121  std::string inputMissing;
122  std::string inputBLL;
123  std::string inputNMF;
124  std::string inputBOL;
125  std::string inputFER;
126  std::string inputExtraH;
127  std::string inputUnSupRinex;
128  std::string inputMissingSPos;
129  std::string inputContLines;
130  std::string inputNoObs;
131  std::string inputSensorType;
132 
133  std::string inputObsHdrStrErr;
134  std::string inputMissingMkr;
135  std::string inputInvTimeFmt;
136  std::string inputFilterTest1;
137  std::string inputFilterTest2;
138  std::string inputFilterTest3;
139  std::string inputFilterTest4;
140  std::string inputV302;
141 
142  std::string outputHardCode;
143  std::string outputExtraOutput;
144  std::string outputContLines;
145  std::string outputDumps;
146  std::string outputExceptions;
147  std::string outputFilterTest;
148  std::string outputV302;
149  std::string outputV211;
150 
152  std::stringstream failDescriptionStream;
153 
154 };
155 
156 
157 //============================================================
158 // Test Class Definitions
159 //============================================================
160 
161 
162 
163 //------------------------------------------------------------
164 // A test to assure that the bistAsString function works as intended
165 //------------------------------------------------------------
166 
168 {
169  TestUtil test0;
170  std::string dataFilePath = gnsstk::getPathData();
171  std::string tempFilePath = gnsstk::getPathTestTemp();
172 
173  //----------------------------------------
174  // Full file paths
175  //----------------------------------------
176  std::string fileSep = gnsstk::getFileSep();
177  std::string dp = dataFilePath + fileSep;
178  std::string tp = tempFilePath + fileSep;
179 
180  inputNormal = dp + "test_input_rinex_met_408_110a.04m";
181  inputMissing = dp + "not-a-real-file-sasquatch.moo";
182  inputBLL = dp + "test_input_rinex_met_BLL.04m";
183  inputNMF = dp + "test_input_rinex_met_NotMetFile.04m";
184  inputBOL = dp + "test_input_rinex_met_BOL.04m";
185  inputFER = dp + "test_input_rinex_met_FER.04m";
186  inputExtraH = dp + "test_input_rinex_met_ExtraH.04m";
187  inputUnSupRinex = dp + "test_input_rinex_met_UnSupRinex.04m";
188  inputMissingSPos = dp + "test_input_rinex_met_MissingEOH.04m";
189  inputContLines = dp + "test_input_rinex_met_ContLines10.04m";
190  inputNoObs = dp + "test_input_rinex_met_NoObsData.04m";
191  inputSensorType = dp + "test_input_rinex_met_SensorTypeError.04m";
192  inputObsHdrStrErr = dp + "test_input_rinex_met_ObsHeaderStringError.04m";
193  inputMissingMkr = dp + "test_input_rinex_met_MissingMarkerName";
194  inputInvTimeFmt = dp + "test_input_rinex_met_InvalidTimeFormat.04m";
195  inputFilterTest1 = dp + "test_input_rinex_met_Filter1.04m";
196  inputFilterTest2 = dp + "test_input_rinex_met_Filter2.04m";
197  inputFilterTest3 = dp + "test_input_rinex_met_Filter3.04m";
198  inputV302 = dp + "test_input_rinex_met_V302.04m";
199 
200  outputHardCode = tp + "test_output_rinex_met_Output.txt";
201  outputExtraOutput = tp + "test_output_rinex_met_ExtraOutput.txt";
202  outputContLines = tp + "test_output_rinex_met_Cont.txt";
203  outputDumps = tp + "test_output_rinex_met_Dumps.txt";
204  outputExceptions = tp + "test_output_rinex_met_DataExceptions.txt";
205  outputFilterTest = tp + "test_output_rinex_met_Filter.txt";
206  outputV302 = tp + "test_output_rinex_met_V302.txt";
207  outputV211 = tp + "test_output_rinex_met_V211.txt";
208 }
209 
210 
212 {
213  TUDEF("RinexMetStream", "open");
214 
215  ifstream fstr(inputMissing.c_str(), ios::in);
216  testFramework.assert(!fstr,
217  "std::ifstream marked good for non-existent file",
218  __LINE__);
219  fstr.close();
220 
221  RinexMetStream mstr(inputMissing.c_str(), ios::in);
222  testFramework.assert(!mstr,
223  "RinexMetStream marked good for non-existent file",
224  __LINE__);
225  mstr.close();
226 
227  return testFramework.countFails();
228 }
229 
230 
231 //------------------------------------------------------------
232 // A test to assure that the bistAsString function works as intended
233 //------------------------------------------------------------
234 
236 {
237  TUDEF( "RinexMetHeader", "bitsAsString" );
238 
239  std::string test_desc =
240  "RinexMetHeader, bitsAsString, file read compared to expected string, did not match";
241 
243 
244  std::string expected_string_a = "RINEX VERSION / TYPE";
245  std::string expected_string_b = "PGM / RUN BY / DATE";
246  std::string expected_string_c = "COMMENT";
247  std::string expected_string_d = "MARKER NAME";
248  std::string expected_string_e = "MARKER NUMBER";
249  std::string expected_string_f = "# / TYPES OF OBSERV";
250  std::string expected_string_g = "SENSOR MOD/TYPE/ACC";
251  std::string expected_string_h = "SENSOR POS XYZ/H";
252  std::string expected_string_i = "END OF HEADER";
253  std::string expected_string_z = "*UNKNOWN/INVALID BITS*";
254 
255  testFramework.assert( expected_string_a == RinexMetHeader.bitsAsString(
256  RinexMetHeader.validVersion) , test_desc, __LINE__ );
257  testFramework.assert( expected_string_b == RinexMetHeader.bitsAsString(
258  RinexMetHeader.validRunBy) , test_desc, __LINE__ );
259  testFramework.assert( expected_string_c == RinexMetHeader.bitsAsString(
260  RinexMetHeader.validComment) , test_desc, __LINE__ );
261  testFramework.assert( expected_string_d == RinexMetHeader.bitsAsString(
262  RinexMetHeader.validMarkerName) , test_desc, __LINE__ );
263  testFramework.assert( expected_string_e == RinexMetHeader.bitsAsString(
264  RinexMetHeader.validMarkerNumber) , test_desc, __LINE__ );
265  testFramework.assert( expected_string_f == RinexMetHeader.bitsAsString(
266  RinexMetHeader.validObsType) , test_desc, __LINE__ );
267  testFramework.assert( expected_string_g == RinexMetHeader.bitsAsString(
268  RinexMetHeader.validSensorType) , test_desc, __LINE__ );
269  testFramework.assert( expected_string_h == RinexMetHeader.bitsAsString(
270  RinexMetHeader.validSensorPos) , test_desc, __LINE__ );
271  testFramework.assert( expected_string_i == RinexMetHeader.bitsAsString(
272  RinexMetHeader.validEoH) , test_desc, __LINE__ );
273  //Default Case
274  testFramework.assert( expected_string_z == RinexMetHeader.bitsAsString(
275  RinexMetHeader.allValid21) , test_desc, __LINE__ );
276 
277  return( testFramework.countFails() );
278 }
279 
280 //------------------------------------------------------------
281 // A test to assure that the version validity bits are what we expect them to be
282 //------------------------------------------------------------
284 {
285  TUDEF( "RinexMetHeader", "bitString" );
286 
287  std::string test_desc =
288  "RinexMetHeader, bitString, test to assure that the version validity bits are what we expect them to be";
289  std::string test_fail = "";
290 
292 
293  std::string sep=", ";
294  std::string expected_string_a = "\"RINEX VERSION / TYPE\"";
295  std::string expected_string_b =
296  "\"RINEX VERSION / TYPE\", \"PGM / RUN BY / DATE\", \"MARKER NAME\", \"# / TYPES OF OBSERV\", \"SENSOR MOD/TYPE/ACC\", \"SENSOR POS XYZ/H\", \"END OF HEADER\"";
297 
298  test_fail = ", validVersion failed";
299  testFramework.assert( expected_string_a == RinexMetHeader.bitString(
300  RinexMetHeader.validVersion, '\"', sep ), test_desc + test_fail, __LINE__ );
301 
302  test_fail = ", allValid21 failed";
303  testFramework.assert( expected_string_b == RinexMetHeader.bitString(
304  RinexMetHeader.allValid21, '\"', sep ), test_desc + test_fail, __LINE__ );
305 
306  test_fail = ", allValid20 failed";
307  testFramework.assert( expected_string_b == RinexMetHeader.bitString(
308  RinexMetHeader.allValid20, '\"', sep ), test_desc + test_fail, __LINE__ );
309  // testFramework.assert( expected_string_b, RinexMetHeader.bitString(RinexMetHeader.allValid20,' ',sep), test_desc + test_fail, __LINE__ );
310 
311  return testFramework.countFails();
312 }
313 
314 //------------------------------------------------------------
315 // A small test of the reallyPutRecord member of the RinexMetHeader
316 // with a few execptions such as an Unsupported Rinex version (e.g. 3.33)
317 // and a Missing Marker Name
318 //------------------------------------------------------------
320 {
321  TUDEF( "RinexMetHeader", "exceptions" );
322 
323  std::string msg_test_desc =
324  "RinexMetHeader, reallyPutRecordTest, exception tests";
325  std::string msg_false_pass =
326  ", should have thrown a gnsstk::Exception but did not.";
327  std::string msg_fail =
328  ", should have thrown a gnsstk::Exception but threw an unexpected exception.";
329  std::string msg_test_detail = "";
330 
332 
333  gnsstk::RinexMetStream UnSupRinex( inputUnSupRinex.c_str() );
334  gnsstk::RinexMetStream MissingMarkerName( inputMissingMkr.c_str() );
335  gnsstk::RinexMetStream output( outputExtraOutput.c_str(),
336  std::ios::out );
337 
338  output.exceptions( std::fstream::failbit );
339  UnSupRinex.exceptions( std::fstream::failbit );
340  MissingMarkerName.exceptions( std::fstream::failbit );
341 
342  //------------------------------------------------------------
343  // Unsupported Rinex
344  //------------------------------------------------------------
345  msg_test_detail = ", Unsupported Rinex version";
346 
347  try
348  {
349  UnSupRinex >> RinexMetHeader;
350  TUFAIL( msg_test_desc + msg_test_detail + msg_false_pass );
351  }
352  catch( gnsstk::Exception e )
353  {
354  TUPASS( msg_test_desc + msg_test_detail );
355  }
356  catch(...)
357  {
358  TUFAIL( msg_test_desc + msg_test_detail + msg_fail );
359  }
360 
361  //------------------------------------------------------------
362  // Missing Marker
363  //------------------------------------------------------------
364  msg_test_detail = ", Missing Marker Name";
365  try
366  {
367  MissingMarkerName >> RinexMetHeader;
368  TUFAIL( msg_test_desc + msg_test_detail + msg_false_pass );
369  }
370  catch( gnsstk::Exception e )
371  {
372  TUPASS( msg_test_desc + msg_test_detail );
373  }
374  catch(...)
375  {
376  TUFAIL( msg_test_desc + msg_test_detail + msg_fail );
377  }
378 
379  return testFramework.countFails();
380 }
381 
382 // ------------------------------------------------------------
383 // This function reads the RINEX MET header from the given FFStream.
384 // If an error is encountered in reading form the stream, the stream
385 // is reset to its original position and its fail-bit is set.
386 // ------------------------------------------------------------
388 {
389  TUDEF( "RinexMetHeader", "exceptions" );
390 
391  std::string msg_test_desc = "";
392  std::string msg_false_pass =
393  ", should have thrown a gnsstk::Exception but did not.";
394  std::string msg_fail =
395  ", should have thrown a gnsstk::Exception but threw an unexpected exception.";
396 
397 
398 
399  //Header file we will be testing on
401 
402  //Normal Met File (No changes, straight from the archive)
403  gnsstk::RinexMetStream Normal( inputNormal.c_str() );
404 
405  //Bad Line Length Met file (Add a space characacter to the end of the first line)
406  gnsstk::RinexMetStream BLL( inputBLL.c_str() );
407 
408  //Not a Met File (Change Met to zet in first line)
409  gnsstk::RinexMetStream NMF( inputNMF.c_str() );
410 
411  //Bad Obs line (Add in something between the MET obs besides space)
412  gnsstk::RinexMetStream BOL( inputBOL.c_str() );
413 
414  //Bad Sesor Type line, Format Error
415  gnsstk::RinexMetStream FER( inputFER.c_str() );
416 
417  //Extra header line with HEADERLINE2
418  gnsstk::RinexMetStream ExtraH( inputExtraH.c_str() );
419 
420  //Unsupported Rinex Version (3.30)
421  gnsstk::RinexMetStream UnSupRinex( inputUnSupRinex.c_str() );
422 
423  //Missing SensorPos
424  gnsstk::RinexMetStream MissingSPos( inputMissingSPos.c_str() );
425 
426  //Error in the part of the header which holds the list of observations within the Met file
427  gnsstk::RinexMetStream ObsHeaderStringError(
428  inputObsHdrStrErr.c_str() );
429 
430  //Error in the sensor type
431  gnsstk::RinexMetStream SensorType( inputSensorType.c_str() );
432 
433  Normal.exceptions( std::fstream::failbit );
434  BLL.exceptions( std::fstream::failbit );
435  NMF.exceptions( std::fstream::failbit );
436  BOL.exceptions( std::fstream::failbit );
437  FER.exceptions( std::fstream::failbit );
438  ExtraH.exceptions( std::fstream::failbit );
439  UnSupRinex.exceptions( std::fstream::failbit );
440  MissingSPos.exceptions( std::fstream::failbit );
441  ObsHeaderStringError.exceptions( std::fstream::failbit );
442  SensorType.exceptions( std::fstream::failbit );
443 
444 
445  //============================================================
446  // Fail any of the following tests which does NOT throw a gnsstk::Exception
447  //============================================================
448 
449  //----------------------------------------
450  //----------------------------------------
451  msg_test_desc = "ExtraH >> RinexMetHeader";
452  try
453  {
454  ExtraH >> RinexMetHeader;
455  TUFAIL(msg_test_desc + msg_false_pass );
456  }
457  catch( gnsstk::Exception e )
458  {
459  TUPASS(msg_test_desc );
460  }
461  catch(...)
462  {
463  TUFAIL(msg_test_desc + msg_fail );
464  }
465 
466  //----------------------------------------
467  //----------------------------------------
468  msg_test_desc = "UnSupRinex >> RinexMetHeader";
469  try
470  {
471  UnSupRinex >> RinexMetHeader;
472  TUFAIL(msg_test_desc + msg_false_pass );
473  }
474  catch( gnsstk::Exception e )
475  {
476  TUPASS(msg_test_desc );
477  }
478  catch(...)
479  {
480  TUFAIL(msg_test_desc + msg_fail );
481  }
482 
483  //----------------------------------------
484  //----------------------------------------
485  msg_test_desc = "MissingSPos >> RinexMetHeader";
486  try
487  {
488  MissingSPos >> RinexMetHeader;
489  TUFAIL(msg_test_desc + msg_false_pass );
490  }
491  catch( gnsstk::Exception e )
492  {
493  TUPASS(msg_test_desc );
494  }
495  catch(...)
496  {
497  TUFAIL(msg_test_desc + msg_fail );
498  }
499 
500  //----------------------------------------
501  //----------------------------------------
502  msg_test_desc = "ObsHeaderStringError >> RinexMetHeader";
503  try
504  {
505  ObsHeaderStringError >> RinexMetHeader;
506  TUFAIL(msg_test_desc + msg_false_pass );
507  }
508  catch( gnsstk::Exception e )
509  {
510  TUPASS(msg_test_desc );
511  }
512  catch(...)
513  {
514  TUFAIL(msg_test_desc + msg_fail );
515  }
516 
517  //----------------------------------------
518  //----------------------------------------
519  msg_test_desc = "SensorType >> RinexMetHeader";
520  try
521  {
522  SensorType >> RinexMetHeader;
523  TUFAIL(msg_test_desc + msg_false_pass );
524  }
525  catch( gnsstk::Exception e )
526  {
527  TUPASS(msg_test_desc );
528  }
529  catch(...)
530  {
531  TUFAIL(msg_test_desc + msg_fail );
532  }
533 
534  //----------------------------------------
535  //----------------------------------------
536  msg_test_desc = "BLL >> RinexMetHeader";
537  try
538  {
539  BLL >> RinexMetHeader;
540  TUFAIL(msg_test_desc + msg_false_pass );
541  }
542  catch( gnsstk::Exception e )
543  {
544  TUPASS(msg_test_desc );
545  }
546  catch(...)
547  {
548  TUFAIL(msg_test_desc + msg_fail );
549  }
550 
551  //----------------------------------------
552  //----------------------------------------
553  msg_test_desc = "NMF >> RinexMetHeader";
554  try
555  {
556  NMF >> RinexMetHeader;
557  TUFAIL(msg_test_desc + msg_false_pass );
558  }
559  catch( gnsstk::Exception e )
560  {
561  TUPASS(msg_test_desc );
562  }
563  catch(...)
564  {
565  TUFAIL(msg_test_desc + msg_fail );
566  }
567 
568  //----------------------------------------
569  //----------------------------------------
570  msg_test_desc = "BOL >> RinexMetHeader";
571  try
572  {
573  BOL >> RinexMetHeader;
574  TUFAIL(msg_test_desc + msg_false_pass );
575  }
576  catch( gnsstk::Exception e )
577  {
578  TUPASS(msg_test_desc );
579  }
580  catch(...)
581  {
582  TUFAIL(msg_test_desc + msg_fail );
583  }
584 
585 
586  //----------------------------------------
587  // Fail the follow test if it throws ANYTHING!
588  //----------------------------------------
589  msg_test_desc = "Normal >> RinexMetHeader";
590  std::string msg_fail_gnsstk =
591  ", should have thrown nothing, but threw a gnsstk::Exception.";
592  std::string msg_fail_other =
593  ", should have thrown nothing, but threw an exception.";
594  try
595  {
596  Normal >> RinexMetHeader;
597  TUPASS(msg_test_desc );
598  }
599  catch( gnsstk::Exception e)
600  {
601  cout << e << endl;
602  TUFAIL(msg_test_desc + msg_fail_gnsstk );
603  }
604  catch(...)
605  {
606  TUFAIL(msg_test_desc + msg_fail_other );
607  }
608 
609 
610 
611  return testFramework.countFails();
612 }
613 
614 //------------------------------------------------------------
615 // This test tests the convertObsType member of RinexMetHeader
616 // This particular test asserts if two Met Types are equal
617 //------------------------------------------------------------
618 
620 {
621  TUDEF( "RinexMetHeader", "convertObsType" );
622  std::string msg_test_desc = "convertObsTypeSTRTest, ";
623  std::string msg_test_fail = "";
624 
626  gnsstk::RinexMetStream Normal( inputNormal.c_str() );
627 
628  Normal >> RinexMetHeader;
629 
637  // gnsstk::RinexMetHeader::RinexMetType KE = RinexMetHeader.convertObsType( "HI" );
638 
639  std::string PRS = "PR";
640  std::string TDS = "TD";
641  std::string HRS = "HR";
642  std::string ZWS = "ZW";
643  std::string ZDS = "ZD";
644  std::string ZTS = "ZT";
645  std::string HIS = "HI";
646 
647  msg_test_fail = "convertObsType(PRS) did not return expected value";
648  testFramework.assert( PR == RinexMetHeader.convertObsType(PRS),
649  msg_test_desc + msg_test_fail, __LINE__ );
650 
651  msg_test_fail = "convertObsType(TDS) did not return expected value";
652  testFramework.assert( TD == RinexMetHeader.convertObsType(TDS),
653  msg_test_desc + msg_test_fail, __LINE__ );
654 
655  msg_test_fail = "convertObsType(HRS) did not return expected value";
656  testFramework.assert( HR == RinexMetHeader.convertObsType(HRS),
657  msg_test_desc + msg_test_fail, __LINE__ );
658 
659  msg_test_fail = "convertObsType(ZWS) did not return expected value";
660  testFramework.assert( ZW == RinexMetHeader.convertObsType(ZWS),
661  msg_test_desc + msg_test_fail, __LINE__ );
662 
663  msg_test_fail = "convertObsType(ZDS) did not return expected value";
664  testFramework.assert( ZD == RinexMetHeader.convertObsType(ZDS),
665  msg_test_desc + msg_test_fail, __LINE__ );
666 
667  msg_test_fail = "convertObsType(ZTS) did not return expected value";
668  testFramework.assert( ZT == RinexMetHeader.convertObsType(ZTS),
669  msg_test_desc + msg_test_fail, __LINE__ );
670 
671  msg_test_fail = "convertObsType(HIS) did not return expected value";
672  testFramework.assert( HI == RinexMetHeader.convertObsType(HIS),
673  msg_test_desc + msg_test_fail, __LINE__ );
674 
675 
676 
677  return testFramework.countFails();
678 }
679 
680 //------------------------------------------------------------
681 //
682 // This test tests the convertObsType member of RinexMetHeader
683 // This particular test asserts if two strings are equal
684 //
685 //------------------------------------------------------------
687 {
688  TUDEF( "RinexMetHeader", "convertObsType" );
689  std::string msg_test_desc = "convertObsTypeHeaderTest, ";
690  std::string msg_test_fail = "";
691 
693  gnsstk::RinexMetStream Normal( inputNormal.c_str() );
694 
695  Normal >> RinexMetHeader;
696 
703  // gnsstk::RinexMetHeader::RinexMetType KE = RinexMetHeader.convertObsType( "ZT" );
704 
705  std::string PRS = "PR";
706  std::string TDS = "TD";
707  std::string HRS = "HR";
708  std::string ZWS = "ZW";
709  std::string ZDS = "ZD";
710  std::string ZTS = "ZT";
711 
712  msg_test_fail = "convertObsType(PR) did not return expected value";
713  testFramework.assert( PRS == RinexMetHeader.convertObsType(PR),
714  msg_test_desc + msg_test_fail, __LINE__ );
715 
716  msg_test_fail = "convertObsType(TD) did not return expected value";
717  testFramework.assert( TDS == RinexMetHeader.convertObsType(TD),
718  msg_test_desc + msg_test_fail, __LINE__ );
719 
720  msg_test_fail = "convertObsType(HR) did not return expected value";
721  testFramework.assert( HRS == RinexMetHeader.convertObsType(HR),
722  msg_test_desc + msg_test_fail, __LINE__ );
723 
724  msg_test_fail = "convertObsType(ZW) did not return expected value";
725  testFramework.assert( ZWS == RinexMetHeader.convertObsType(ZW),
726  msg_test_desc + msg_test_fail, __LINE__ );
727 
728  msg_test_fail = "convertObsType(ZD) did not return expected value";
729  testFramework.assert( ZDS == RinexMetHeader.convertObsType(ZD),
730  msg_test_desc + msg_test_fail, __LINE__ );
731 
732  msg_test_fail = "convertObsType(ZT) did not return expected value";
733  testFramework.assert( ZTS == RinexMetHeader.convertObsType(ZT),
734  msg_test_desc + msg_test_fail, __LINE__ );
735 
736 
737  //----------------------------------------
738  // Fail if the following throws anything but a FFStreamError
739  //----------------------------------------
740  msg_test_desc = "convertObsType( \"KE\" ), should throw gnsstk::FFStreamError";
741  std::string msg_false_pass = ", but threw no exceptions.";
742  std::string msg_fail_other = ", but threw a different exception.";
743  try
744  {
746  TUFAIL(msg_test_desc + msg_false_pass );
747  }
748  catch(gnsstk::FFStreamError)
749  {
750  TUPASS(msg_test_desc );
751  }
752  catch(...)
753  {
754  TUFAIL(msg_test_desc + msg_fail_other );
755  }
756 
757 
758 
759 
760  return testFramework.countFails();
761 }
762 
763 //------------------------------------------------------------
764 //
765 // This test checks to make sure that the internal members of
766 // the RinexMetHeader are as we think they should be.
767 // Also at the end of this test, we check and make sure our
768 // output file is equal to our input
769 //
770 //------------------------------------------------------------
772 {
773  TUDEF( "RinexMetHeader", "version" );
774  std::string msg_test_desc = "RinexMetHeader data member value tests, ";
775  std::string msg_test_fail = "";
776 
777  gnsstk::RinexMetStream testRinexMetStream( inputNormal.c_str() );
778  gnsstk::RinexMetStream out( outputHardCode.c_str(), std::ios::out );
779  gnsstk::RinexMetHeader testRinexMetHeader;
780 
781  testRinexMetStream >> testRinexMetHeader;
782 
783  //============================================================
784  // Test RinexMet Header content
785  //============================================================
786 
787  msg_test_fail = "RinexMetHeader.version, does not match expected value ";
788  testFramework.assert( testRinexMetHeader.version == 2.1,
789  msg_test_desc + msg_test_fail, __LINE__ );
790 
791  msg_test_fail = "RinexMetHeader.fileType, does not match expected value ";
792  testFramework.assert( testRinexMetHeader.fileType == (std::string)"Meteorological",
793  msg_test_desc + msg_test_fail, __LINE__ );
794 
795  msg_test_fail = "RinexMetHeader.fileProgram, does not match expected value ";
796  testFramework.assert( testRinexMetHeader.fileProgram == (std::string)"GFW - RMW",
797  msg_test_desc + msg_test_fail, __LINE__ );
798 
799  msg_test_fail = "RinexMetHeader.fileAgency, does not match expected value ";
800  testFramework.assert( testRinexMetHeader.fileAgency == (std::string)"NIMA",
801  msg_test_desc + msg_test_fail, __LINE__ );
802 
803  msg_test_fail = "RinexMetHeader.date, does not match expected value ";
804  testFramework.assert( testRinexMetHeader.date == (std::string)
805  "04/18/2004 23:58:50", msg_test_desc + msg_test_fail, __LINE__ );
806 
807 
808  std::vector<std::string>::const_iterator itr1 =
809  testRinexMetHeader.commentList.begin();
810  msg_test_fail = "weather data correct values message does not match";
811  while( itr1 != testRinexMetHeader.commentList.end() )
812  {
813  testFramework.assert( (*itr1) == (std::string)
814  "Some weather data may have corrected values", msg_test_desc + msg_test_fail,
815  __LINE__ );
816 
817  itr1++;
818  }
819 
820  msg_test_fail = "RinexMetHeader.markerName, does not match expected value ";
821  testFramework.assert( testRinexMetHeader.markerName == (std::string)"85408",
822  msg_test_desc + msg_test_fail, __LINE__ );
823 
824  msg_test_fail = "RinexMetHeader.markerNumber, does not match expected value ";
825  testFramework.assert( testRinexMetHeader.markerNumber == (std::string)"85408",
826  msg_test_desc + msg_test_fail, __LINE__ );
827 
828 
829  msg_test_fail =
830  "testRinexMetHeader.convertObsType(iterator) did not return expected value PR";
831  vector<RinexMetHeader::RinexMetType>::const_iterator itr2 =
832  testRinexMetHeader.obsTypeList.begin();
833  if( itr2 != testRinexMetHeader.obsTypeList.end() )
834  {
835  testFramework.assert( testRinexMetHeader.convertObsType(*itr2) == (std::string)"PR",
836  msg_test_desc + msg_test_fail, __LINE__ );
837  itr2++;
838  }
839  else
840  {
841  TUFAIL(msg_test_desc );
842  }
843 
844 
845  msg_test_fail =
846  "testRinexMetHeader.convertObsType(iterator) did not return expected value TD";
847  if( itr2 != testRinexMetHeader.obsTypeList.end() )
848  {
849  testFramework.assert( testRinexMetHeader.convertObsType(*itr2) == (std::string)"TD",
850  msg_test_desc + msg_test_fail, __LINE__ );
851  itr2++;
852  }
853  else
854  {
855  TUFAIL(msg_test_desc );
856  }
857 
858 
859  msg_test_fail =
860  "testRinexMetHeader.convertObsType(iterator) did not return expected value HI";
861  if( itr2 != testRinexMetHeader.obsTypeList.end() )
862  {
863  testFramework.assert( testRinexMetHeader.convertObsType(*itr2) == (std::string)"HI",
864  msg_test_desc + msg_test_fail, __LINE__ );
865  }
866  else
867  {
868  TUFAIL(msg_test_desc );
869  }
870 
871 
872  //------------------------------------------------------------
873  //------------------------------------------------------------
874  vector<RinexMetHeader::sensorType>::const_iterator itr3 =
875  testRinexMetHeader.sensorTypeList.begin();
876  if( itr3 != testRinexMetHeader.sensorTypeList.end() )
877  {
878  msg_test_fail =
879  "RinexMetHeader.sensorTypeList iterator.model did not return expected value Vaisala";
880  testFramework.assert( (*itr3).model == (std::string)"Vaisala",
881  msg_test_desc + msg_test_fail, __LINE__ );
882 
883  msg_test_fail =
884  "RinexMetHeader.sensorTypeList iterator.type did not return expected value PTB220";
885  testFramework.assert( (*itr3).type == (std::string)"PTB220",
886  msg_test_desc + msg_test_fail, __LINE__ );
887 
888  msg_test_fail =
889  "RinexMetHeader.sensorTypeList iterator.accuracy did not return expected value 0.1";
890  testFramework.assert( (*itr3).accuracy == 0.1, msg_test_desc + msg_test_fail,
891  __LINE__ );
892 
893  msg_test_fail =
894  "RinexMetHeader.convertObsType iterator.obsType did not return expected value PR";
895  testFramework.assert( testRinexMetHeader.convertObsType((*itr3).obsType) ==
896  (std::string)"PR", msg_test_desc + msg_test_fail, __LINE__ );
897 
898  itr3++;
899  }
900  else
901  {
902  // Must fail all four tests above
903  msg_test_fail =
904  "RinexMetHeader.sensorTypeList iterator.model test is in a block that failed";
905  TUFAIL(msg_test_desc + msg_test_fail );
906  msg_test_fail =
907  "RinexMetHeader.sensorTypeList iterator.type test is in a block that failed";
908  TUFAIL(msg_test_desc + msg_test_fail );
909  msg_test_fail =
910  "RinexMetHeader.sensorTypeList iterator.accuracy test is in a block that failed";
911  TUFAIL(msg_test_desc + msg_test_fail );
912  msg_test_fail =
913  "RinexMetHeader.convertObsType iterator.obsType test is in a block that failed";
914  TUFAIL(msg_test_desc + msg_test_fail );
915  }
916 
917 
918  //------------------------------------------------------------
919  //------------------------------------------------------------
920  if( itr3 != testRinexMetHeader.sensorTypeList.end() )
921  {
922  msg_test_fail =
923  "RinexMetHeader.sensorTypeList iterator.model did not return expected value Vaisala";
924  testFramework.assert( (*itr3).model == (std::string)"Vaisala",
925  msg_test_desc + msg_test_fail, __LINE__ );
926 
927  msg_test_fail =
928  "RinexMetHeader.sensorTypeList iterator.type did not return expected value HMP230";
929  testFramework.assert( (*itr3).type == (std::string)"HMP230",
930  msg_test_desc + msg_test_fail, __LINE__ );
931 
932  msg_test_fail =
933  "RinexMetHeader.sensorTypeList iterator.accuracy did not return expected value 0.1";
934  testFramework.assert( (*itr3).accuracy == 0.1, msg_test_desc + msg_test_fail,
935  __LINE__ );
936 
937  msg_test_fail =
938  "RinexMetHeader.convertObsType iterator.obsType did not return expected value TD";
939  testFramework.assert( testRinexMetHeader.convertObsType((*itr3).obsType) ==
940  (std::string)"TD", msg_test_desc + msg_test_fail, __LINE__ );
941 
942  itr3++;
943  }
944  else
945  {
946  // Must fail all four tests above
947  msg_test_fail =
948  "RinexMetHeader.sensorTypeList iterator.model test is in a block that failed";
949  TUFAIL(msg_test_desc + msg_test_fail );
950  msg_test_fail =
951  "RinexMetHeader.sensorTypeList iterator.type test is in a block that failed";
952  TUFAIL(msg_test_desc + msg_test_fail );
953  msg_test_fail =
954  "RinexMetHeader.sensorTypeList iterator.accuracy test is in a block that failed";
955  TUFAIL(msg_test_desc + msg_test_fail );
956  msg_test_fail =
957  "RinexMetHeader.convertObsType iterator.obsType test is in a block that failed";
958  TUFAIL(msg_test_desc + msg_test_fail );
959  }
960 
961 
962  //------------------------------------------------------------
963  //------------------------------------------------------------
964  if( itr3 != testRinexMetHeader.sensorTypeList.end() )
965  {
966  msg_test_fail =
967  "RinexMetHeader.sensorTypeList iterator.model did not return expected value Vaisala";
968  testFramework.assert( (*itr3).model == (std::string)"Vaisala",
969  msg_test_desc + msg_test_fail, __LINE__ );
970 
971  msg_test_fail =
972  "RinexMetHeader.sensorTypeList iterator.type did not return expected value HMP230";
973  testFramework.assert( (*itr3).type == (std::string)"HMP230",
974  msg_test_desc + msg_test_fail, __LINE__ );
975 
976  msg_test_fail =
977  "RinexMetHeader.sensorTypeList iterator.accuracy did not return expected value 0.1";
978  testFramework.assert( (*itr3).accuracy == 0.1, msg_test_desc + msg_test_fail,
979  __LINE__ );
980 
981  msg_test_fail =
982  "RinexMetHeader.convertObsType iterator.obsType did not return expected value HI";
983  testFramework.assert( testRinexMetHeader.convertObsType((*itr3).obsType) ==
984  (std::string)"HI", msg_test_desc + msg_test_fail, __LINE__ );
985 
986  itr3++;
987 
988  }
989  else
990  {
991  // Must fail all four tests above
992  msg_test_fail =
993  "RinexMetHeader.sensorTypeList iterator.model test is in a block that failed";
994  TUFAIL(msg_test_desc + msg_test_fail );
995  msg_test_fail =
996  "RinexMetHeader.sensorTypeList iterator.type test is in a block that failed";
997  TUFAIL(msg_test_desc + msg_test_fail );
998  msg_test_fail =
999  "RinexMetHeader.sensorTypeList iterator.accuracy test is in a block that failed";
1000  TUFAIL(msg_test_desc + msg_test_fail );
1001  msg_test_fail =
1002  "RinexMetHeader.convertObsType iterator.obsType test is in a block that failed";
1003  TUFAIL(msg_test_desc + msg_test_fail );
1004  }
1005 
1006  //------------------------------------------------------------
1007  //------------------------------------------------------------
1008  vector<RinexMetHeader::sensorPosType>::const_iterator itr4 =
1009  testRinexMetHeader.sensorPosList.begin();
1010 
1011  if( itr4 != testRinexMetHeader.sensorPosList.end() )
1012  {
1013  msg_test_fail =
1014  "RinexMetHeader.sensorPosType iterator.position[0] did not return expected value";
1015  testFramework.assert( (*itr4).position[0] == -740289.8363,
1016  msg_test_desc + msg_test_fail, __LINE__ );
1017 
1018  msg_test_fail =
1019  "RinexMetHeader.sensorPosType iterator.position[1] did not return expected value";
1020  testFramework.assert( (*itr4).position[1] == -5457071.7414,
1021  msg_test_desc + msg_test_fail, __LINE__ );
1022 
1023  msg_test_fail =
1024  "RinexMetHeader.sensorPosType iterator.position[2] did not return expected value";
1025  testFramework.assert( (*itr4).position[2] == 3207245.6207,
1026  msg_test_desc + msg_test_fail, __LINE__ );
1027 
1028  msg_test_fail =
1029  "RinexMetHeader.sensorPosType iterator.height did not return expected value";
1030  testFramework.assert( (*itr4).height == 0.0000,
1031  msg_test_desc + msg_test_fail, __LINE__ );
1032 
1033  msg_test_fail =
1034  "RinexMetHeader.convertObsType iterator.obsType did not return expected value PR";
1035  testFramework.assert( testRinexMetHeader.convertObsType((*itr4).obsType) ==
1036  (std::string) "PR", msg_test_desc + msg_test_fail, __LINE__ );
1037 
1038  itr4++;
1039 
1040  }
1041  else
1042  {
1043  // Must fail all five tests above
1044  msg_test_fail =
1045  "RinexMetHeader.sensorPosType iterator.position[0] test is in a block that failed";
1046  TUFAIL(msg_test_desc + msg_test_fail );
1047  msg_test_fail =
1048  "RinexMetHeader.sensorPosType iterator.position[1] test is in a block that failed";
1049  TUFAIL(msg_test_desc + msg_test_fail );
1050  msg_test_fail =
1051  "RinexMetHeader.sensorPosType iterator.position[2] test is in a block that failed";
1052  TUFAIL(msg_test_desc + msg_test_fail );
1053  msg_test_fail =
1054  "RinexMetHeader.sensorPosType iterator.height test is in a block that failed";
1055  TUFAIL(msg_test_desc + msg_test_fail );
1056  msg_test_fail =
1057  "RinexMetHeader.convertObsType iterator.obsType test is in a block that failed";
1058  TUFAIL(msg_test_desc + msg_test_fail );
1059  }
1060 
1061  //------------------------------------------------------------
1062  //------------------------------------------------------------
1063  if( itr4 != testRinexMetHeader.sensorPosList.end() )
1064  {
1065  msg_test_fail =
1066  "RinexMetHeader.sensorPosType iterator.position[0] did not return expected value";
1067  testFramework.assert( (*itr4).position[0] == -740289.8363,
1068  msg_test_desc + msg_test_fail, __LINE__ );
1069 
1070  msg_test_fail =
1071  "RinexMetHeader.sensorPosType iterator.position[1] did not return expected value";
1072  testFramework.assert( (*itr4).position[1] == -5457071.7414,
1073  msg_test_desc + msg_test_fail, __LINE__ );
1074 
1075  msg_test_fail =
1076  "RinexMetHeader.sensorPosType iterator.position[2] did not return expected value";
1077  testFramework.assert( (*itr4).position[2] == 3207245.6207,
1078  msg_test_desc + msg_test_fail, __LINE__ );
1079 
1080  msg_test_fail =
1081  "RinexMetHeader.sensorPosType iterator.height did not return expected value";
1082  testFramework.assert( (*itr4).height == 0.0000,
1083  msg_test_desc + msg_test_fail, __LINE__ );
1084 
1085  msg_test_fail =
1086  "RinexMetHeader.convertObsType iterator.obsType did not return expected value TD";
1087  testFramework.assert( testRinexMetHeader.convertObsType((*itr4).obsType) ==
1088  (std::string) "TD", msg_test_desc + msg_test_fail, __LINE__ );
1089 
1090  }
1091  else
1092  {
1093  // Must fail all five tests above
1094  msg_test_fail =
1095  "RinexMetHeader.sensorPosType iterator.position[0] test is in a block that failed";
1096  TUFAIL(msg_test_desc + msg_test_fail );
1097  msg_test_fail =
1098  "RinexMetHeader.sensorPosType iterator.position[1] test is in a block that failed";
1099  TUFAIL(msg_test_desc + msg_test_fail );
1100  msg_test_fail =
1101  "RinexMetHeader.sensorPosType iterator.position[2] test is in a block that failed";
1102  TUFAIL(msg_test_desc + msg_test_fail );
1103  msg_test_fail =
1104  "RinexMetHeader.sensorPosType iterator.height test is in a block that failed";
1105  TUFAIL(msg_test_desc + msg_test_fail );
1106  msg_test_fail =
1107  "RinexMetHeader.convertObsType iterator.obsType test is in a block that failed";
1108  TUFAIL(msg_test_desc + msg_test_fail );
1109  }
1110  //End of Header
1111 
1112  //============================================================
1113  // Test the RinexMetData content
1114  //============================================================
1115 
1116  out << testRinexMetHeader;
1117  gnsstk::RinexMetData testRinexMetData;
1118  testRinexMetStream >> testRinexMetData;
1119  gnsstk::CivilTime TimeGuess(2004,4,19,0,0,0);
1120 
1121  msg_test_desc = "RinexMetData data member value tests, ";
1122  msg_test_fail = "";
1123 
1124 
1125 
1126  msg_test_fail = "RinexMetData.time did not equal TimeGuess";
1127  testFramework.assert( testRinexMetData.time == (gnsstk::CommonTime)TimeGuess,
1128  msg_test_desc + msg_test_fail, __LINE__ );
1129 
1130  msg_test_fail = "RinexMetData.data for PR does not match expected value ";
1131  testFramework.assert( testRinexMetData.data[testRinexMetHeader.convertObsType( "PR" )]
1132  == 992.6, msg_test_desc + msg_test_fail, __LINE__ );
1133 
1134  msg_test_fail = "RinexMetData.data for TD does not match expected value ";
1135  testFramework.assert( testRinexMetData.data[testRinexMetHeader.convertObsType( "TD" )]
1136  == 23.9, msg_test_desc + msg_test_fail, __LINE__ );
1137 
1138  msg_test_fail = "RinexMetData.data for HI does not match expected value ";
1139  testFramework.assert( testRinexMetData.data[testRinexMetHeader.convertObsType( "HI" )]
1140  == 59.7, msg_test_desc + msg_test_fail, __LINE__ );
1141 
1142  out << testRinexMetData;
1143  testRinexMetStream >> testRinexMetData;
1144  gnsstk::CivilTime TimeGuess2(2004,4,19,0,15,0);
1145 
1146  msg_test_fail = "RinexMetData.time did not equal TimeGuess2";
1147  testFramework.assert( testRinexMetData.time == (gnsstk::CommonTime)TimeGuess2,
1148  msg_test_desc + msg_test_fail, __LINE__ );
1149 
1150  msg_test_fail = "RinexMetData.data for PR does not match expected value";
1151  testFramework.assert( testRinexMetData.data[testRinexMetHeader.convertObsType( "PR" )]
1152  == 992.8, msg_test_desc + msg_test_fail, __LINE__ );
1153 
1154  msg_test_fail = "RinexMetData.data for TD does not match expected value";
1155  testFramework.assert( testRinexMetData.data[testRinexMetHeader.convertObsType( "TD" )]
1156  == 23.6, msg_test_desc + msg_test_fail, __LINE__ );
1157 
1158  msg_test_fail = "RinexMetData.data for HI does not match expected value";
1159  testFramework.assert( testRinexMetData.data[testRinexMetHeader.convertObsType( "HI" )]
1160  == 61.6, msg_test_desc + msg_test_fail, __LINE__ );
1161 
1162  out << testRinexMetData;
1163  while( testRinexMetStream >> testRinexMetData )
1164  {
1165  out << testRinexMetData;
1166  }
1167 
1168  msg_test_fail =
1169  "files not equal, inputNormal and outputHardCode";
1170  testFramework.assert( testFramework.fileEqualTest( inputNormal, outputHardCode,
1171  2), msg_test_desc + msg_test_fail, __LINE__ );
1172 
1173  gnsstk::RinexMetStream MetDumps( outputDumps.c_str(), std::ios::out );
1174  testRinexMetHeader.dump( MetDumps );
1175  testRinexMetData.dump( MetDumps );
1176 
1177 
1178  return testFramework.countFails();
1179 }
1180 
1181 //------------------------------------------------------------
1182 //
1183 // This test covers are of the RinexMetHeader and Data which
1184 // deal with continuation lines for the observations
1185 //
1186 //------------------------------------------------------------
1187 
1189 {
1190  TUDEF( "RinexMetHeader", "continuation" );
1191  std::string msg_test_desc = "continuation file comparison";
1192  std::string msg_test_fail =
1193  ", files are not equal, inputContLines outputContLines";
1194  std::string msg_fail_exception = ", threw unexpected exception";
1195 
1196  gnsstk::RinexMetStream RinexMetStream( inputContLines.c_str() );
1197  gnsstk::RinexMetStream out( outputContLines.c_str(), std::ios::out );
1198  gnsstk::RinexMetStream MetDumps( outputDumps.c_str(), std::ios::out );
1201 
1202  try
1203  {
1205  out << RinexMetHeader;
1206 
1207  RinexMetHeader.dump( MetDumps );
1208  RinexMetData.dump( MetDumps );
1210  RinexMetData.dump( MetDumps );
1211  out << RinexMetData;
1212  while( RinexMetStream >> RinexMetData )
1213  {
1214  out << RinexMetData;
1215  }
1216 
1217  testFramework.assert( testFramework.fileEqualTest( inputContLines,
1218  outputContLines, 2), msg_test_desc + msg_test_fail, __LINE__ );
1219  }
1220  catch(...)
1221  {
1222  TUFAIL(msg_test_desc + msg_fail_exception );
1223  }
1224  return testFramework.countFails();
1225 }
1226 
1227 //------------------------------------------------------------
1228 //
1229 // This test covers several RinexMetData exceptions including
1230 // a test with no observations data for the
1231 // listed header Obs and an invalid time format
1232 //
1233 // Note: assuming this means that these test SHOULD throw a gnsstk::Exception
1234 // Throwing any exception other than gnsstk::Exception is considered a failure.
1235 // Throwing nothing is assumed also to be a failure of the test.
1236 //------------------------------------------------------------
1238 {
1239  TUDEF( "RinexMetHeader", "nodata" );
1240  std::string msg_test_desc = "dataExceptionsTest, ";
1241  std::string msg_test_fail = "";
1242 
1243  gnsstk::RinexMetStream NoObs( inputNoObs.c_str() );
1244  gnsstk::RinexMetStream InvalidTimeFormat( inputInvTimeFmt.c_str() );
1245  gnsstk::RinexMetStream out( outputExceptions.c_str(), std::ios::out );
1248 
1249  NoObs.exceptions( std::fstream::failbit );
1250  InvalidTimeFormat.exceptions( std::fstream::failbit );
1251  out.exceptions( std::fstream::failbit );
1252 
1253  try
1254  {
1255  NoObs >> rmh;
1256  try
1257  {
1258  out << rmh;
1259  TUPASS("header");
1260  }
1261  catch (...)
1262  {
1263  TUFAIL("Failed to write valid header");
1264  }
1265 
1266  try
1267  {
1268  while( NoObs >> rme )
1269  {
1270  out << rme;
1271  }
1272  TUPASS("data");
1273  }
1274  catch (...)
1275  {
1276  TUFAIL("Failed to read/write valid data");
1277  }
1278  try
1279  {
1280  InvalidTimeFormat >> rme;
1281  TUFAIL("Read improperly formatted data");
1282  }
1283  catch (...)
1284  {
1285  TUPASS("exception");
1286  }
1287  InvalidTimeFormat.clear();
1288  // try to read a second improperly formatted record.. but is
1289  // it really doing it, or has the stream backed-up to before
1290  // the previous bad record and it's just trying to read the
1291  // same broken one?
1292  try
1293  {
1294  InvalidTimeFormat >> rme;
1295  TUFAIL("Read improperly formatted data");
1296  }
1297  catch (...)
1298  {
1299  TUPASS("exception");
1300  }
1301  InvalidTimeFormat.clear();
1302  }
1303  catch (...)
1304  {
1305  TUFAIL(msg_test_desc);
1306  }
1307  return testFramework.countFails();
1308 }
1309 
1310 //------------------------------------------------------------
1311 //
1312 // Test for several of the members within RinexMetFilterOperators
1313 // including merge, LessThanSimple, EqualsSimple,
1314 // and LessThanFull.
1315 //
1316 //------------------------------------------------------------
1318 {
1319  TUDEF( "RinexMetStream", "filter" );
1320  std::string msg_test_desc = "filterOperatorsTest, ";
1321  std::string msg_test_fail = "";
1322 
1323  try
1324  {
1325 
1326  gnsstk::RinexMetStream FilterStream1( inputFilterTest1.c_str() );
1327  FilterStream1.open( inputFilterTest1.c_str(), std::ios::in );
1328  gnsstk::RinexMetStream FilterStream2( inputFilterTest2.c_str() );
1329  gnsstk::RinexMetStream FilterStream3( inputFilterTest3.c_str() );
1330  gnsstk::RinexMetStream out( outputFilterTest.c_str(), std::ios::out );
1331 
1332  gnsstk::RinexMetHeader FilterHeader1;
1333  gnsstk::RinexMetHeader FilterHeader2;
1334  gnsstk::RinexMetHeader FilterHeader3;
1335 
1336  gnsstk::RinexMetData FilterData1;
1337  gnsstk::RinexMetData FilterData2;
1338  gnsstk::RinexMetData FilterData3;
1339  gnsstk::RinexMetData rmdata;
1340 
1341  FilterStream1 >> FilterHeader1;
1342  FilterStream2 >> FilterHeader2;
1343  FilterStream3 >> FilterHeader3;
1344 
1345  while( FilterStream1 >> rmdata )
1346  {
1347  FilterData1 = rmdata;
1348  }
1349  while( FilterStream2 >> rmdata )
1350  {
1351  FilterData2 = rmdata;
1352  }
1353  while( FilterStream3 >> rmdata )
1354  {
1355  FilterData3 = rmdata;
1356  }
1357 
1359  merged( FilterHeader1 );
1360  merged( FilterHeader2 );
1362  out << merged.theHeader;
1363 
1365 
1366  msg_test_fail =
1367  "Check to see if two equivalent files have the same times. They DO NOT.";
1368  testFramework.assert( EqualsSimple(FilterData1, FilterData2) == true,
1369  msg_test_desc + msg_test_fail, __LINE__ );
1370 
1371  msg_test_fail =
1372  "Check to see if two files with different times have the same time values. They DO.";
1373  testFramework.assert( EqualsSimple(FilterData1, FilterData3) == false,
1374  msg_test_desc + msg_test_fail, __LINE__ );
1375 
1377  msg_test_fail =
1378  "Check to see if one file occurred earlier than another using equivalent files. One is found to be earlier than the other.";
1379  testFramework.assert( LessThanSimple(FilterData1, FilterData2) == false,
1380  msg_test_desc + msg_test_fail, __LINE__ );
1381 
1382  msg_test_fail =
1383  "Check to see if one file occurred earlier than another using two files with different times. The earlier file is not found to be earlier.";
1384  testFramework.assert( LessThanSimple(FilterData1, FilterData3) == true,
1385  msg_test_desc + msg_test_fail, __LINE__ );
1386 
1387  gnsstk::RinexMetDataOperatorLessThanFull LessThanFull(merged.obsSet);
1388 
1389  msg_test_fail =
1390  "Perform the full less than comparison on two identical files. FilterData1 has been found to be different than FilterData2.";
1391  testFramework.assert( LessThanFull(FilterData1, FilterData2) == false,
1392  msg_test_desc + msg_test_fail, __LINE__ );
1393 
1394  msg_test_fail =
1395  "Perform the full less than comparison on two identical files. FilterData1 has been found to be different than FilterData2.";
1396  testFramework.assert( LessThanFull(FilterData2, FilterData1) == false,
1397  msg_test_desc + msg_test_fail, __LINE__ );
1398 
1399  msg_test_fail =
1400  "Perform the full less than comparison on two different files. FilterData1, an earlier date, has been found to NOT be less than FilterData3.";
1401  testFramework.assert( LessThanFull(FilterData1, FilterData3) == true,
1402  msg_test_desc + msg_test_fail, __LINE__ );
1403 
1404  msg_test_fail =
1405  "Perform the full less than comparison on two different files. FilterData3, a later date, has been found to be less than FilterData1.";
1406  testFramework.assert( LessThanFull(FilterData3, FilterData1) == false,
1407  msg_test_desc + msg_test_fail, __LINE__ );
1408 
1413  gnsstk::RinexMetDataFilterTime FilterTime(Start,End);
1414  gnsstk::RinexMetDataFilterTime FilterTime2(Start2,End2);
1415 
1416  msg_test_fail =
1417  "FilterTime(FilterData1) == true, should evaluate as true but evaluated as false";
1418  testFramework.assert( FilterTime(FilterData1) == true, msg_test_desc + msg_test_fail,
1419  __LINE__ );
1420 
1421  msg_test_fail =
1422  "FilterTime2(FilterData1) == false, should evaluate as true but evaluated as false";
1423  testFramework.assert( FilterTime2(FilterData1) == false,
1424  msg_test_desc + msg_test_fail, __LINE__ );
1425  }
1426  catch(gnsstk::Exception& exc)
1427  {
1428  cout << exc << endl;
1429  msg_test_fail = "Unexpected exception was thrown";
1430  TUFAIL(msg_test_desc + msg_test_fail );
1431  }
1432  catch(...)
1433  {
1434  msg_test_fail = "Unexpected exception was thrown";
1435  TUFAIL(msg_test_desc + msg_test_fail );
1436  }
1437 
1438  return testFramework.countFails();
1439 }
1440 
1441 
1442 //------------------------------------------------------------
1443 //
1444 // Test version 302 input and output
1445 //
1446 //------------------------------------------------------------
1447 // Helper function for versionTest(). Creates a new Rinex file @outFile
1448 // of version @outVersion using the header and data from @inFile.
1449 // return true if @outFile == @expFile
1450 bool makeAndCompare(string inFile, string outFile, string expFile, double outVersion)
1451 {
1452  TUDEF( "RinexMetData", "versionTest" );
1453  gnsstk::RinexMetStream inStream( inFile.c_str() );
1454  gnsstk::RinexMetStream outStream( outFile.c_str(), std::ios::out );
1455  gnsstk::RinexMetHeader testHeader;
1456 
1457  inStream.exceptions(ifstream::failbit);
1458  outStream.exceptions(ofstream::failbit);
1459 
1460  try
1461  {
1462  inStream >> testHeader;
1463  testHeader.version = outVersion;
1464 
1465  outStream << testHeader;
1466 
1467  gnsstk::RinexMetData testData;
1468  while( inStream >> testData )
1469  {
1470  outStream << testData;
1471  }
1472  }
1473  catch(Exception e)
1474  {
1475  return false;
1476  }
1477  return testFramework.fileEqualTest( expFile, outFile, 2);
1478 }
1479 
1481 {
1482  TUDEF( "RinexMetData", "versionTest" );
1483 
1484  //input version 2.11, output version 3.02
1485  TUASSERT(makeAndCompare(inputNormal, outputV302, inputV302, 3.02));
1486  //input version 3.02, output version 3.02
1487  TUASSERT(makeAndCompare(inputV302, outputV302, inputV302, 3.02));
1488  //input version 3.02, output version 2.11
1489  TUASSERT(makeAndCompare(inputV302, outputV211, inputNormal, 2.11));
1490 
1491  TURETURN();
1492 }
1493 
1494 //============================================================
1495 // Run all the test methods defined above
1496 //============================================================
1497 
1498 int main()
1499 {
1500  int errorTotal = 0;
1501  RinexMet_T testClass;
1502 
1503  errorTotal += testClass.bitsAsStringTest();
1504  errorTotal += testClass.bitStringTest();
1505  errorTotal += testClass.reallyPutRecordTest();
1506  errorTotal += testClass.reallyGetRecordTest();
1507  errorTotal += testClass.convertObsTypeSTRTest();
1508  errorTotal += testClass.convertObsTypeHeaderTest();
1509  errorTotal += testClass.hardCodeTest();
1510  errorTotal += testClass.versionTest();
1511  errorTotal += testClass.continuationTest();
1512  errorTotal += testClass.dataExceptionsTest();
1513  errorTotal += testClass.filterOperatorsTest();
1514  errorTotal += testClass.openMissingFileTest();
1515 
1516  cout << "Total Failures for " << __FILE__ << ": " << errorTotal << endl;
1517 
1518  return( errorTotal );
1519 }
RinexMet_T::inputBOL
std::string inputBOL
Definition: RinexMet_T.cpp:124
gnsstk::RinexMetData
Definition: RinexMetData.hpp:71
gnsstk::RinexMetStream
Definition: RinexMetStream.hpp:70
RinexMet_T::dataExceptionsTest
int dataExceptionsTest()
Definition: RinexMet_T.cpp:1237
gnsstk::RinexMetHeader::bitsAsString
static std::string bitsAsString(validBits b)
Definition: RinexMetHeader.hpp:146
RinexMet_T::inputFilterTest3
std::string inputFilterTest3
Definition: RinexMet_T.cpp:138
RinexMet_T::filterOperatorsTest
int filterOperatorsTest()
Definition: RinexMet_T.cpp:1317
gnsstk::RinexMetDataOperatorLessThanSimple
Compares only times.
Definition: RinexMetFilterOperators.hpp:121
RinexMet_T::continuationTest
int continuationTest()
Definition: RinexMet_T.cpp:1188
gnsstk::RinexMetHeader::commentList
std::vector< std::string > commentList
A list of comments.
Definition: RinexMetHeader.hpp:203
RinexMet_T::reallyPutRecordTest
int reallyPutRecordTest()
Definition: RinexMet_T.cpp:319
RinexMet_T::inputNoObs
std::string inputNoObs
Definition: RinexMet_T.cpp:130
gnsstk::RinexMetHeader::bitString
static std::string bitString(unsigned long vb, char quote='\"', std::string sep=", ")
Definition: RinexMetHeader.cpp:71
RinexMet_T::inputSensorType
std::string inputSensorType
Definition: RinexMet_T.cpp:131
StringUtils.hpp
gnsstk::RinexMetHeaderTouchHeaderMerge
Definition: RinexMetFilterOperators.hpp:152
gnsstk::RinexMetHeader::allValid20
@ allValid20
Definition: RinexMetHeader.hpp:137
dataFilePath
string dataFilePath
Definition: Rinex3Obs_FromScratch_T.cpp:51
gnsstk::RinexMetDataOperatorLessThanFull
Definition: RinexMetFilterOperators.hpp:64
RinexMet_T::bitStringTest
int bitStringTest()
Definition: RinexMet_T.cpp:283
TUFAIL
#define TUFAIL(MSG)
Definition: TestUtil.hpp:228
RinexMet_T::outputDumps
std::string outputDumps
Definition: RinexMet_T.cpp:145
RinexMet_T::failDescriptionString
std::string failDescriptionString
Definition: RinexMet_T.cpp:151
RinexMet_T::outputV211
std::string outputV211
Definition: RinexMet_T.cpp:149
RinexMet_T::RinexMet_T
RinexMet_T()
Definition: RinexMet_T.cpp:74
RinexMet_T::outputExceptions
std::string outputExceptions
Definition: RinexMet_T.cpp:146
RinexMet_T::inputFilterTest2
std::string inputFilterTest2
Definition: RinexMet_T.cpp:137
gnsstk::CommonTime::BEGINNING_OF_TIME
static const GNSSTK_EXPORT CommonTime BEGINNING_OF_TIME
earliest representable CommonTime
Definition: CommonTime.hpp:102
gnsstk::RinexMetHeader::validVersion
@ validVersion
Set if the RINEX version is valid.
Definition: RinexMetHeader.hpp:124
gnsstk::RinexMetStream::open
virtual void open(const char *fn, std::ios::openmode mode)
overrides open to reset the header
Definition: RinexMetStream.cpp:70
gnsstk::RinexMetHeader::RinexMetType
RinexMetType
Enum for the different types of data in this file.
Definition: RinexMetHeader.hpp:81
gnsstk::RinexMetHeaderTouchHeaderMerge::obsSet
std::set< RinexMetHeader::RinexMetType > obsSet
Definition: RinexMetFilterOperators.hpp:208
gnsstk
For Sinex::InputHistory.
Definition: BasicFramework.cpp:50
gnsstk::Exception
Definition: Exception.hpp:151
RinexMet_T::hardCodeTest
int hardCodeTest()
Definition: RinexMet_T.cpp:771
RinexMet_T::inputV302
std::string inputV302
Definition: RinexMet_T.cpp:140
gnsstk::CommonTime::END_OF_TIME
static const GNSSTK_EXPORT CommonTime END_OF_TIME
latest representable CommonTime
Definition: CommonTime.hpp:104
gnsstk::RinexMetDataFilterTime
This filter will return true for any data not within the specified time range.
Definition: RinexMetFilterOperators.hpp:212
TUASSERT
#define TUASSERT(EXPR)
Definition: TestUtil.hpp:63
RinexMet_T::inputUnSupRinex
std::string inputUnSupRinex
Definition: RinexMet_T.cpp:127
RinexMet_T::inputFilterTest4
std::string inputFilterTest4
Definition: RinexMet_T.cpp:139
gnsstk::RinexMetHeader::dump
virtual void dump(std::ostream &s) const
A debug function that outputs the header to s.
Definition: RinexMetHeader.cpp:446
RinexMet_T::inputNMF
std::string inputNMF
Definition: RinexMet_T.cpp:123
TestUtil.hpp
gnsstk::RinexMetHeader::validSensorPos
@ validSensorPos
Set if Sensor position is valid.
Definition: RinexMetHeader.hpp:131
gnsstk::RinexMetHeader::validObsType
@ validObsType
Set if Num/Types of Obs is valid.
Definition: RinexMetHeader.hpp:129
RinexMet_T::bitsAsStringTest
int bitsAsStringTest()
Definition: RinexMet_T.cpp:235
TURETURN
#define TURETURN()
Definition: TestUtil.hpp:232
gnsstk::RinexMetHeaderTouchHeaderMerge::theHeader
RinexMetHeader theHeader
Definition: RinexMetFilterOperators.hpp:207
RinexMetBase.hpp
TUPASS
#define TUPASS(MSG)
Definition: TestUtil.hpp:230
RinexMet_T::openMissingFileTest
int openMissingFileTest()
Definition: RinexMet_T.cpp:211
gnsstk::RinexMetHeader::convertObsType
static RinexMetType convertObsType(const std::string &oneObs)
Definition: RinexMetHeader.cpp:464
RinexMet_T::convertObsTypeSTRTest
int convertObsTypeSTRTest()
Definition: RinexMet_T.cpp:619
gnsstk::RinexMetHeader::validEoH
@ validEoH
Set if the end of header is valid.
Definition: RinexMetHeader.hpp:133
gnsstk::CommonTime
Definition: CommonTime.hpp:84
RinexMet_T::inputObsHdrStrErr
std::string inputObsHdrStrErr
Definition: RinexMet_T.cpp:133
RinexMet_T::inputFER
std::string inputFER
Definition: RinexMet_T.cpp:125
makeAndCompare
bool makeAndCompare(string inFile, string outFile, string expFile, double outVersion)
Definition: RinexMet_T.cpp:1450
RinexMet_T::tempFilePath
std::string tempFilePath
Definition: RinexMet_T.cpp:103
gnsstk::RinexMetHeader::validComment
@ validComment
Set if the comments are valid. Very subjective...
Definition: RinexMetHeader.hpp:126
RinexMet_T::reallyGetRecordTest
int reallyGetRecordTest()
Definition: RinexMet_T.cpp:387
RinexMet_T::inputMissingMkr
std::string inputMissingMkr
Definition: RinexMet_T.cpp:134
RinexMet_T::inputMissingSPos
std::string inputMissingSPos
Definition: RinexMet_T.cpp:128
TUDEF
#define TUDEF(CLASS, METHOD)
Definition: TestUtil.hpp:56
RinexMetFilterOperators.hpp
RinexMetHeader.hpp
main
int main()
Definition: RinexMet_T.cpp:1498
gnsstk::CivilTime
Definition: CivilTime.hpp:55
RinexMet_T::outputFilterTest
std::string outputFilterTest
Definition: RinexMet_T.cpp:147
RinexMet_T::inputExtraH
std::string inputExtraH
Definition: RinexMet_T.cpp:126
RinexMet_T::inputMissing
std::string inputMissing
Definition: RinexMet_T.cpp:121
gnsstk::RinexMetHeader::validMarkerNumber
@ validMarkerNumber
Set if the Marker Number is valid.
Definition: RinexMetHeader.hpp:128
RinexMetStream.hpp
RinexMetData.hpp
RinexMet_T::convertObsTypeHeaderTest
int convertObsTypeHeaderTest()
Definition: RinexMet_T.cpp:686
Exception.hpp
std
Definition: Angle.hpp:142
gnsstk::RinexMetHeader::validSensorType
@ validSensorType
Set if Sensor Mod/Type/Acc is valid.
Definition: RinexMetHeader.hpp:130
RinexMet_T::outputHardCode
std::string outputHardCode
Definition: RinexMet_T.cpp:142
gnsstk::RinexMetHeader::allValid21
@ allValid21
Definition: RinexMetHeader.hpp:140
RinexMet_T::versionTest
int versionTest()
Definition: RinexMet_T.cpp:1480
RinexMet_T::inputFilterTest1
std::string inputFilterTest1
Definition: RinexMet_T.cpp:136
RinexMet_T::outputContLines
std::string outputContLines
Definition: RinexMet_T.cpp:144
RinexMet_T::dataFilePath
std::string dataFilePath
Definition: RinexMet_T.cpp:99
RinexMet_T::outputExtraOutput
std::string outputExtraOutput
Definition: RinexMet_T.cpp:143
gnsstk::RinexMetHeader::validMarkerName
@ validMarkerName
Set if the Marker Name is valid.
Definition: RinexMetHeader.hpp:127
RinexMet_T::failDescriptionStream
std::stringstream failDescriptionStream
Definition: RinexMet_T.cpp:152
gnsstk::RinexMetHeader::version
double version
RINEX Version.
Definition: RinexMetHeader.hpp:197
RinexMet_T::inputInvTimeFmt
std::string inputInvTimeFmt
Definition: RinexMet_T.cpp:135
RinexMet_T::~RinexMet_T
~RinexMet_T()
Definition: RinexMet_T.cpp:79
gnsstk::ZW
@ ZW
Definition: NBTropModel.cpp:98
gnsstk::RinexMetHeader::validRunBy
@ validRunBy
Set if the Run-by value is valid.
Definition: RinexMetHeader.hpp:125
RinexMet_T::inputBLL
std::string inputBLL
Definition: RinexMet_T.cpp:122
gnsstk::ZT
@ ZT
Definition: NBTropModel.cpp:98
gnsstk::TestUtil
Definition: TestUtil.hpp:265
RinexMet_T::inputNormal
std::string inputNormal
Definition: RinexMet_T.cpp:120
RinexMet_T
Definition: RinexMet_T.cpp:69
gnsstk::RinexMetDataOperatorEqualsSimple
Compares only times.
Definition: RinexMetFilterOperators.hpp:134
RinexMet_T::init
void init()
Definition: RinexMet_T.cpp:167
RinexMet_T::outputV302
std::string outputV302
Definition: RinexMet_T.cpp:148
gnsstk::RinexMetData::dump
virtual void dump(std::ostream &s) const
Definition: RinexMetData.cpp:285
tempFilePath
string tempFilePath
Definition: Rinex3Obs_FromScratch_T.cpp:50
RinexMet_T::inputContLines
std::string inputContLines
Definition: RinexMet_T.cpp:129
gnsstk::RinexMetHeader
Definition: RinexMetHeader.hpp:70


gnsstk
Author(s):
autogenerated on Wed Oct 25 2023 02:40:41