Exemplo n.º 1
0
/// returns 0 if all tests pass
int main()
{
   using gpstk::DayTime;
   
   try
   {
      cout << "BOT:" << DayTime(gpstk::DayTime::BEGINNING_OF_TIME) << endl;
      cout << "EOT:" << DayTime(gpstk::DayTime::END_OF_TIME) << endl;
     
      DayTime dt;
      dt.setSystemTime();
      cout << "Check that the output matches the current UTC time." << endl
           << "string                         printf()" << endl;

      dtft(cout, dt, "mjd:  %Q (%.0Q)");
      dtft(cout, dt, "mjd:  %5.3Q");
      dtft(cout, dt, "mdy:  %02m/%02d/%04Y");
      dtft(cout, dt, "hms:  %02H:%02M:%02S");
      dtft(cout, dt, "hms:  %02H:%02M:%06.3f");
      dtft(cout, dt, "cal:  %A, %B %d, %Y");
      dtft(cout, dt, "week: %F(%G)");
      dtft(cout, dt, "sow:  %g");
      dtft(cout, dt, "sow:  %06.3g");
      dtft(cout, dt, "doy:  %j:%s");
      dtft(cout, dt, "dow:  %w");
      dtft(cout, dt, "z:    %Z (%z)");
      dtft(cout, dt, "unix: %U.%06u");

      cout << endl
           << "The following functions use DayTime::setToString()" << endl;

      string format = "%02m/%02d/%04Y %02H:%02M:%02S";
      string st = dt.printf(format);

      DayTime q;
      q.setToString(st, format);
      dtft(cout, q, format);

      cout << "Tests complete." << endl;
      return 0;
   }
   catch(gpstk::Exception& e)
   {
      cout << e << endl;
   }
   catch(...)
   {
      cout << "Some other exception thrown..." << endl;
   }

   cout << "Exiting with exceptions." << endl;
   return -1;
}
Exemplo n.º 2
0
/// returns 0 if all tests pass
int main()
{
   using gpstk::DayTime;
   
   try
   {
      DayTime::setDayTimeTolerance(DayTime::DAYTIME_TOLERANCE); // microsecond tolerance

      cout << endl;
      cout << "DayTime conversion tests." << endl << endl;
      
      cout << "All comparisons accurate to " << DayTime::DAYTIME_TOLERANCE;
      cout << " seconds." << endl << endl;
      

      bool cumulativeResult = true;


      cout << "Testing constructors using documented dates." << endl;
      cout << endl;
      
      
         // Directly from ICD-GPS-200
         // Beginning of GPS Time, as defined by ICD-GPS-200
      cumulativeResult = cumulativeResult &&
                             testConstructors(1980,1,6,0,0,0,
                                              0, 0., 0,
                                              1981,
                                              44244.);
      
         // From GPS Signals and Performan, Misra and Enge, p. 91
         // GPS 10 bit week rollover epoch
      cumulativeResult = cumulativeResult &&
                             testConstructors(1999,8,22,0,0,0,
                                              0, 0., 0,
                                              2000,
                                              51412.);
      
         // From Hoffman-Wellenhof, et al. 
         // The J2000 standard epoch
      cumulativeResult = cumulativeResult &&
                             testConstructors(2000,1,1,12,0,0,
                                              1042, 561600., 374400,
                                              2000,
                                              2451545 - 2400000.5);


      cout << endl << "Testing mutators using documented dates." << endl << endl;
      
         // Directly from ICD-GPS-200
         // Beginning of GPS Time, as defined by ICD-GPS-200
      cumulativeResult = cumulativeResult &&
                             testMutators(1980,1,6,0,0,0,
                                          6, 0.,
                                          0, 0., 0,
                                          1981,
                                          44244.);
      
         // From GPS Signals and Performan, Misra and Enge, p. 91
         // GPS 10 bit week rollover epoch
      cumulativeResult = cumulativeResult &&
                             testMutators(1999,8,22,0,0,0,
                                          234, 0.,
                                          0, 0., 0,
                                          2000,
                                          51412.);
      
         // From Hoffman-Wellenhof, et al. 
         // The J2000 standard epoch
      cumulativeResult = cumulativeResult &&
                             testMutators(2000,1,1,12,0,0,
                                          1, 43200.,
                                          1042, 561600., 374400,
                                          2000,
                                          2451545 - 2400000.5);

         // Random accessor/mutator tests
      cout << endl;
      cout << "Testing accessors and mutators using randomly generated dates.";
      cout << endl << endl;
      
      gpstk::DayTime dtBegin(1995,1,1,0,0,0), dtEnd(2015,1,1,0,0,0);
      cumulativeResult = cumulativeResult &&
                         testRandomAccessors( dtBegin, dtEnd, 20);


         // Wrap it up, folks
      cout << endl;
      cout << setw(34);
      cout << DayTime().printf("Completed on %B %d, %Y %H:%02M:%02S");
      cout << endl << endl;
      
      int ret = 0;
      if (cumulativeResult)
         cout << "All comparison tests PASSED." << endl;
      else
      {
         cout << "One ore more comparison tests FAILED." << endl;
         ret = 1;
      }
      
      return ret;
   }
   catch(gpstk::Exception& e)
   {
      cout << e << endl;
   }
   catch(...)
   {
      cout << "Some other exception thrown..." << endl;
   }

   cout << "Exiting with exceptions." << endl;
   return -1;
}