当前位置: 首页>>代码示例>>C++>>正文


C++ CommonTime类代码示例

本文整理汇总了C++中CommonTime的典型用法代码示例。如果您正苦于以下问题:C++ CommonTime类的具体用法?C++ CommonTime怎么用?C++ CommonTime使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CommonTime类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GPSWeekSecond

void OrbElemRinex::adjustBeginningValidity()
{
    if (!dataLoaded()) return;

    // The nominal beginning of validity is calculated from
    // the fit interval and the Toe.  In RINEX the fit duration
    // in hours is stored in the file.
    long  oneHalfInterval = ((long)fitDuration/2) * 3600;

    // If we assume this is the SECOND set of elements in a set
    // (which is an assumption of this function - see the .hpp) then
    // the "small offset in Toe" will actually push the Toe-oneHalfInterval
    // too early. For example, consider the following case.
    //         Toe : 19:59:44  (really near 20:00:00)
    //  first xMit : 18:00:00  (nominal)
    // Blindly setting beginValid top Toe - 1/2 fit interval will
    // result in 17:59:44.  But 18:00:00 actually is the right answer
    // because the -16 second offset is an artifact.
    //
    // Therefore, we are FIRST going to remove that offset,
    // THEN determine beginValid.
    long sow = (long) (static_cast<GPSWeekSecond>(ctToe)).sow;
    short week = (static_cast<GPSWeekSecond>(ctToe)).week;
    sow = sow + (3600 - (sow%3600));
    CommonTime adjustedToe = GPSWeekSecond(week, (double) sow);
    adjustedToe.setTimeSystem(TimeSystem::GPS);

    beginValid = adjustedToe - oneHalfInterval;
    return;
}
开发者ID:xiangyan66,项目名称:GPSTk,代码行数:30,代码来源:OrbElemRinex.cpp

示例2: throw

CommonTime Rinex3ObsData::parseTime(const string& line,
                                    const Rinex3ObsHeader& hdr,
                                    const TimeSystem& ts) const
throw(FFStreamError)
{
    try
    {
        // check if the spaces are in the right place - an easy
        // way to check if there's corruption in the file
        if( (line[ 1] != ' ') || (line[ 6] != ' ') || (line[ 9] != ' ') ||
                (line[12] != ' ') || (line[15] != ' ') || (line[18] != ' ') ||
                (line[29] != ' ') || (line[30] != ' '))
        {
            FFStreamError e("Invalid time format");
            GPSTK_THROW(e);
        }

        // if there's no time, just return a bad time
        if(line.substr(2,27) == string(27, ' '))
            return CommonTime::BEGINNING_OF_TIME;

        int year, month, day, hour, min;
        double sec;

        year  = asInt(   line.substr( 2,  4));
        month = asInt(   line.substr( 7,  2));
        day   = asInt(   line.substr(10,  2));
        hour  = asInt(   line.substr(13,  2));
        min   = asInt(   line.substr(16,  2));
        sec   = asDouble(line.substr(19, 11));

        // Real Rinex has epochs 'yy mm dd hr 59 60.0' surprisingly often.
        double ds = 0;
        if(sec >= 60.)
        {
            ds = sec;
            sec = 0.0;
        }

        CommonTime rv = CivilTime(year,month,day,hour,min,sec).convertToCommonTime();
        if(ds != 0) rv += ds;

        rv.setTimeSystem(ts);

        return rv;
    }
    // string exceptions for substr are caught here
    catch (std::exception &e)
    {
        FFStreamError err("std::exception: " + string(e.what()));
        GPSTK_THROW(err);
    }
    catch (gpstk::Exception& e)
    {
        FFStreamError err(e);
        GPSTK_THROW(err);
    }
}  // end parseTime
开发者ID:rumkex,项目名称:GPSTk,代码行数:58,代码来源:Rinex3ObsData.cpp

示例3: throw

   void UnixTime::convertFromCommonTime( const CommonTime& ct )
      throw( InvalidRequest )
   {
         /// This is the earliest CommonTime for which UnixTimes are valid.
      static const CommonTime MIN_CT = UnixTime();
         /// This is the latest CommonTime for which UnixTimes are valid.
         /// (2^31 - 1) s and 999999 us
      static const CommonTime MAX_CT = UnixTime(2147483647, 999999);

      if ( ct < MIN_CT || ct > MAX_CT )
      {
         InvalidRequest ir("Unable to convert given CommonTime to UnixTime.");
         GPSTK_THROW(ir);
      }
                             
      long jday, sod;
      double fsod;
      ct.get( jday, sod, fsod );
      
      tv.tv_sec = (jday - MJD_JDAY - UNIX_MJD) * SEC_PER_DAY + sod;
      
         // round to the nearest microsecond
      tv.tv_usec = static_cast<time_t>( fsod * 1e6 + 0.5 ) ;
      
      if (tv.tv_usec >= 1000000) 
      {
         tv.tv_usec -= 1000000; 
         ++tv.tv_sec; 
      }
   }
开发者ID:loongfee,项目名称:ossim-svn,代码行数:30,代码来源:UnixTime.cpp

示例4: toFromCommonTimeTest

      // Test will check converting to/from CommonTime.
   unsigned toFromCommonTimeTest()
   {
      TUDEF("IRNWeekSecond", "isValid");

      IRNWeekSecond compare(0,10.0,TimeSystem::IRN); //Initialize an object
      CommonTime truth;
      long truthDay, truthSOD;
      double truthFSOD;
      truth.set(2451412, 43210,0.0,TimeSystem::IRN);

         //--------------------------------------------------------------------
         //Is the time after the BEGINNING_OF_TIME?
         //--------------------------------------------------------------------
      TUASSERT(compare.convertToCommonTime() > CommonTime::BEGINNING_OF_TIME);

         //--------------------------------------------------------------------
         //Is the set object valid?
         //--------------------------------------------------------------------
      TUASSERT(compare.isValid());

      CommonTime test = compare.convertToCommonTime(); //Convert to CommonTime
      long testDay, testSOD;
      double testFSOD;
      test.get(testDay, testSOD, testFSOD);
      truth.get(truthDay, truthSOD, truthFSOD);
      
      // Currently, IRNWeekSecond does not convert to proper CommonTime
      // These tests will be valid and will be uncommented once issue_248 has been 
      // resolved and merged into master.
      // TUASSERTE(long, truthDay, testDay); 
      // TUASSERTE(long, truthSOD, testSOD);
      // TUASSERTFE(truthFSOD, testFSOD);

      IRNWeekSecond test2;
      test2.convertFromCommonTime(test); //Convert From
      testFramework.changeSourceMethod("CommonTimeConversion");
         //--------------------------------------------------------------------
         //Is the result of conversion the same?
         //--------------------------------------------------------------------
      TUASSERTE(TimeSystem, compare.getTimeSystem(), test2.getTimeSystem());
      TUASSERTE(int, compare.week, test2.week);
      TUASSERTFE(compare.sow, test2.sow);

      //TUASSERT(test2 == test);

      TURETURN();
   }
开发者ID:SGL-UT,项目名称:GPSTk,代码行数:48,代码来源:IRNWeekSecond_T.cpp

示例5: resetTest

        //============================================================
        // Test Suite: resetTest()
        //============================================================
        //
        // Test will check the reset method.
        //
        //============================================================
        int resetTest( void )
        {
            TestUtil testFramework( "CommonTime", "reset" , __FILE__, __LINE__ );

            CommonTime Compare; Compare.set(1000,200,0.2); // Initialize with value
            long day, sod;
            double fsod;
            Compare.reset(); // Reset it
            Compare.get(day,sod,fsod);

            testFramework.assert( TimeSystem(0) == Compare.getTimeSystem(), "Was the time system reset to expectation?", __LINE__  );
            testFramework.assert( 0 == day,  "Was the day value reset to expectation?",  __LINE__ );
            testFramework.assert( 0 == sod,  "Was the sod value reset to expectation?",  __LINE__ );
            testFramework.assert( 0 == fsod, "Was the fsod value reset to expectation?", __LINE__ );

            return testFramework.countFails();
        }
开发者ID:vestuto,项目名称:GPSTk,代码行数:24,代码来源:CommonTime_T.cpp

示例6: convertFromCommonTime

   void JulianDate::convertFromCommonTime( const CommonTime& ct )
   {
      long jday, sod;
      double fsod;
      ct.get( jday, sod, fsod, timeSystem );

      jd =   static_cast<long double>( jday ) +
           (   static_cast<long double>( sod )
             + static_cast<long double>( fsod ) ) * DAY_PER_SEC
           - 0.5;
   }
开发者ID:Milfhunter,项目名称:gpstk,代码行数:11,代码来源:JulianDate.cpp

示例7: temp_jd

   CommonTime JulianDate::convertToCommonTime() const
   {
      try
      {
         long double temp_jd( jd + 0.5 );
         long jday( static_cast<long>( temp_jd ) );
         long double sod =
            ( temp_jd - static_cast<long double>( jday ) ) * SEC_PER_DAY;

         CommonTime ct;
         return ct.set( jday,
                        static_cast<long>( sod ),
                        static_cast<double>( sod - static_cast<long>( sod ) ),
                        timeSystem );
      }
      catch (InvalidParameter& ip)
      {
         InvalidRequest ir(ip);
         GPSTK_THROW(ir);
      }
   }
开发者ID:Milfhunter,项目名称:gpstk,代码行数:21,代码来源:JulianDate.cpp

示例8: MJDEpoch

   CommonTime WeekSecond::convertToCommonTime() const
   {
      try
      {
	      //int dow = static_cast<int>( sow * DAY_PER_SEC );
         // Appears to have rounding issues on 32-bit platforms

         int dow = static_cast<int>( sow / SEC_PER_DAY );
         // NB this assumes MJDEpoch is an integer - what if epoch H:M:S != 0:0:0 ?
         long jday = MJD_JDAY + MJDEpoch() + (7 * week) + dow;
         double sod(sow - SEC_PER_DAY * dow);
         CommonTime ct;
         return ct.set( jday,
                        static_cast<long>(sod),
                        sod - static_cast<long>(sod),
                        timeSystem );
      }
      catch (InvalidParameter& ip)
      {
         GPSTK_RETHROW(ip);
      }
   }
开发者ID:Milfhunter,项目名称:gpstk,代码行数:22,代码来源:WeekSecond.cpp

示例9: toReturn

   // Utility routine for getXvt and addEphemeris to convert time systems.
   // Convert ttag to the target time system, using the first appropriate correction
   // in the list, and return it. If no correction is found, ttag is unchanged and
   // an exception is thrown.
   CommonTime Rinex3EphemerisStore::correctTimeSystem(const CommonTime ttag,
                                                      const TimeSystem targetSys)
      const
   {
      CommonTime toReturn(ttag);
      TimeSystem fromSys(ttag.getTimeSystem());

      // is a conversion necessary?
      if(fromSys == targetSys)
         return toReturn;

      // first correct for leap seconds
      const CivilTime civt(ttag);
      double dt = TimeSystem::Correction(fromSys, targetSys,
                              civt.year, civt.month, civt.day);
      toReturn += dt;
      toReturn.setTimeSystem(targetSys);
      // the corrected timetag: now only the system, not the value, matters
      toReturn.setTimeSystem(targetSys);

      // look up the TimeSystemCorr in list, and do the conversion
      map<string, TimeSystemCorrection>::const_iterator it;
      for(it = mapTimeCorr.begin(); it != mapTimeCorr.end(); ++it) {
         if(it->second.isConverterFor(fromSys, targetSys)) {
            dt = it->second.Correction(ttag);
            toReturn += dt;
            return toReturn;
         }
      }

      // failure
      InvalidRequest e("Unable to convert time systems from "
         + ttag.getTimeSystem().asString() + " to " + targetSys.asString());
      GPSTK_THROW(e);

      return toReturn;      // never reached, satisfy some compilers
   }
开发者ID:Milfhunter,项目名称:gpstk,代码行数:41,代码来源:Rinex3EphemerisStore.cpp

示例10: convertFromCommonTime

   void WeekSecond::convertFromCommonTime( const CommonTime& ct )
   {
      if(static_cast<MJD>(ct).mjd < MJDEpoch())
      {
         InvalidRequest ir("Unable to convert to Week/Second - before Epoch.");
         GPSTK_THROW(ir);
      }

      long jday, sod;
      double fsod;
      ct.get( jday, sod, fsod, timeSystem );
         // find the number of days since the beginning of the Epoch
      jday -= MJD_JDAY + MJDEpoch();
         // find out how many weeks that is
      week = static_cast<int>( jday / 7 );
         // find out what the day of week is
      jday %= 7;

      sow = static_cast<double>( jday * SEC_PER_DAY + sod ) + fsod;
   }
开发者ID:Milfhunter,项目名称:gpstk,代码行数:20,代码来源:WeekSecond.cpp

示例11: timeSystemTest

        //============================================================
        // Test Suite: timeSystemTest()
        //============================================================
        //
        // Test will check the TimeSystem comparisons when using
        // the comparison operators.
        //
        //============================================================
        int timeSystemTest( void )
        {
            TestUtil testFramework( "CommonTime", "Differing TimeSystem == Operator", __FILE__, __LINE__ );

            CommonTime GPS1;       GPS1.set( 1000, 200, 0.2, TimeSystem(2) );
            CommonTime GPS2;       GPS2.set( 100,  200, 0.2, TimeSystem(2) );
            CommonTime UTC1;       UTC1.set( 1000, 200, 0.2, TimeSystem(5) );
            CommonTime UNKNOWN; UNKNOWN.set( 1000, 200, 0.2, TimeSystem(0) );
            CommonTime ANY;         ANY.set( 1000, 200, 0.2, TimeSystem(1) );

            //----------------------------------------
            // ???
            //----------------------------------------
            testFramework.assert( !(GPS1 == GPS2), "Verify same Time System but different time inequality", __LINE__ );
            testFramework.assert( GPS1.getTimeSystem() == GPS2.getTimeSystem(), "Verify same Time System equality", __LINE__ );

            //----------------------------------------
            // Differing TimeSystem != Operator
            //----------------------------------------
            testFramework.changeSourceMethod( "Differing TimeSystem != Operator" );
            testFramework.assert( GPS1 != UTC1,    "Verify different Time System but same time inequality", __LINE__ );
            testFramework.assert( GPS1 != UNKNOWN, "Verify different Time System but same time inequality", __LINE__ );

            //----------------------------------------
            // ANY TimeSystem == Operator
            //----------------------------------------
            testFramework.changeSourceMethod( "ANY TimeSystem == Operator" );
            testFramework.assert( GPS1 == ANY,    "Verify TimeSystem=ANY does not matter in TimeSystem=GPS comparisons",    __LINE__ );
            testFramework.assert( UTC1 == ANY,    "Verify TimeSystem=ANY does not matter in TimeSystem=UTC comparisons",    __LINE__ );
            testFramework.assert( UNKNOWN == ANY, "Verify TimeSystem=ANY does not matter in TimeSystem=UNKOWN comparisons", __LINE__ );

            //----------------------------------------
            // ANY TimeSystem < Operator
            //----------------------------------------
            testFramework.changeSourceMethod( "ANY TimeSystem < Operator" );
            testFramework.assert( !(GPS2 == ANY) && (GPS2 < ANY), "Verify TimeSystem=ANY does not matter in other operator comparisons", __LINE__ );

            //----------------------------------------
            // setTimeSystem
            //----------------------------------------
            testFramework.changeSourceMethod( "setTimeSystem" );
            UNKNOWN.setTimeSystem( TimeSystem(2) ); //Set the Unknown TimeSystem
            testFramework.assert( UNKNOWN.getTimeSystem()==TimeSystem(2), "Ensure resetting a Time System changes it", __LINE__ );

            //----------------------------------------
            // The End!
            //----------------------------------------
            return testFramework.countFails();
        }
开发者ID:vestuto,项目名称:GPSTk,代码行数:57,代码来源:CommonTime_T.cpp

示例12: throw

   void ANSITime::convertFromCommonTime( const CommonTime& ct )
      throw(InvalidRequest)
   {
         /// This is the earliest CommonTime for which ANSITimes are valid.
      static const CommonTime MIN_CT = ANSITime(0);
         /// This is the latest CommonTime for which ANSITimes are valid.
         /// 2^31 - 1 seconds
      static const CommonTime MAX_CT = ANSITime(2147483647);

      if ( ct < MIN_CT || ct > MAX_CT )
      {
         InvalidRequest ir("Unable to convert given CommonTime to ANSITime.");
         GPSTK_THROW(ir);
      }

      long jday, sod;
      double fsod;
      ct.get( jday, sod, fsod );
      
      time = 
         static_cast<time_t>((jday - MJD_JDAY - UNIX_MJD) * SEC_PER_DAY + sod);
   }
开发者ID:ianmartin,项目名称:GPSTk,代码行数:22,代码来源:ANSITime.cpp

示例13: rolloverTest

        //============================================================
        // Test Suite: rolloverTest()
        //============================================================
        //
        // Test to check arithmetic operations function properly when
        // rolling over or under the three time variables
        //
        //============================================================
        int rolloverTest( void )
        {
            TestUtil testFramework( "CommonTime", "addSeconds", __FILE__, __LINE__ );

	    CommonTime  fsodRollover;  fsodRollover.set(10 , 6789 , 0.000999);
            CommonTime  msodRollover;  msodRollover.set(10 , 86399, 0.0001  );
            CommonTime  dayRollunder;  dayRollunder.set(10 , 2    , 0.0001  );
            CommonTime msodRollunder; msodRollunder.set(10 , 10   , 0.000001);

            CommonTime  expectedfsodROver;  expectedfsodROver.set(10, 6789 , 0.001000);
            CommonTime  expectedmsodROver;  expectedmsodROver.set(11, 0    , 0.0001);
            CommonTime  expectedDayRUnder;  expectedDayRUnder.set( 9, 86399, 0.0001); 
            CommonTime expectedmsodRUnder; expectedmsodRUnder.set(10, 9    , 0.999999);

            long    obtainedDay,  expectedDay;
            long   obtainedMsod, expectedMsod;
            double obtainedFsod, expectedFsod;
	    double diff;
            long   incrementSecLong   = 1L      , decrementSecLong   = -3L;
            double incrementSecDouble = 0.000001, decrementSecDouble = -0.000002;

            //--------------------------------
	    //Rollover Tests
            //--------------------------------

            //fsod Rollover test
            fsodRollover.addSeconds(incrementSecDouble);
            fsodRollover.get(obtainedDay,obtainedMsod,obtainedFsod);
            expectedfsodROver.get(expectedDay,expectedMsod,expectedFsod);

            testFramework.assert(obtainedDay == expectedDay  , "Rollover of fsod affected day value" , __LINE__);
            testFramework.assert(obtainedMsod == expectedMsod, "Rollover of fsod did not change msod", __LINE__);
            diff = fabs(obtainedFsod - expectedFsod);
            testFramework.assert(diff < eps, "fsod did not rollover properly"      , __LINE__);
 

            //msod Rollover test
            msodRollover.addSeconds(incrementSecLong);
            msodRollover.get(obtainedDay,obtainedMsod,obtainedFsod);
            expectedmsodROver.get(expectedDay,expectedMsod,expectedFsod);

            testFramework.assert(obtainedDay == expectedDay  , "Rollover of msod did not change day" , __LINE__);
            testFramework.assert(obtainedMsod == expectedMsod, "msod did not rollover properly"       , __LINE__);
            diff = fabs(obtainedFsod - expectedFsod);
            testFramework.assert(diff < eps, "Rollover of msod affected fsod oddly", __LINE__);


            //--------------------------------
	    //Rollunder Tests
            //--------------------------------

            //fsod Rollover test
            dayRollunder.addSeconds(decrementSecLong);
            dayRollunder.get(obtainedDay,obtainedMsod,obtainedFsod);
            expectedDayRUnder.get(expectedDay,expectedMsod,expectedFsod);

            testFramework.assert(obtainedDay == expectedDay  , "Rollunder of msod did not change day" , __LINE__);
            testFramework.assert(obtainedMsod == expectedMsod, "msod did not rollunder properly"       , __LINE__);
            diff = fabs(obtainedFsod - expectedFsod);
            testFramework.assert(diff < eps, "Rollunder of msod affected fsod oddly", __LINE__);
 

            //msod Rollover test
            msodRollunder.addSeconds(decrementSecDouble);
            msodRollunder.get(obtainedDay,obtainedMsod,obtainedFsod);
            expectedmsodRUnder.get(expectedDay,expectedMsod,expectedFsod);

            testFramework.assert(obtainedDay == expectedDay  , "Rollunder of fsod affected day value" , __LINE__);
            testFramework.assert(obtainedMsod == expectedMsod, "Rollunder of fsod did not change msod", __LINE__);
            diff = fabs(obtainedFsod - expectedFsod);
            testFramework.assert(diff < eps, "fsod did not rollunder properly"      , __LINE__);

            return testFramework.countFails();
        }
开发者ID:vestuto,项目名称:GPSTk,代码行数:82,代码来源:CommonTime_T.cpp

示例14: operatorTest

        //============================================================
        // Test Suite: operatorTest()
        //============================================================
        //
        // Test the comparison operators
        //
        //============================================================
        int operatorTest( void )
        {
            TestUtil testFramework( "CommonTime", "Differing TimeSystem, Operator ==", __FILE__, __LINE__ );

            CommonTime Compare; Compare.set(1000,200,0.2); // Initialize with value
            CommonTime LessThanDay; LessThanDay.set(100,200,0.2); // Initialize with smaller day value
            CommonTime LessThanSecond; LessThanSecond.set(1000,20,0.2); // Initialize with smaller second value
            CommonTime LessThanFSecond; LessThanFSecond.set(1000,200,0.1); // Initialize with smaller fractional second value
            CommonTime CompareCopy(Compare); // Initialize with copy constructor

            testFramework.assert( Compare == CompareCopy,    "GPSWeekZCount operator ==, Are equivalent objects equivalent?",     __LINE__ );
            testFramework.assert( !(Compare == LessThanDay), "GPSWeekZCount operator !=, Are non-equivalent objects equivalent?", __LINE__ );

            //----------------------------------------
            // Operator !=
            //----------------------------------------
            testFramework.changeSourceMethod( "Operator !=" );
            testFramework.assert( Compare != LessThanDay,     "GPSWeekZCount operator !=, Are non-equivalent objects not equivalent?", __LINE__ );
            testFramework.assert( Compare != LessThanSecond,  "GPSWeekZCount operator !=, Are non-equivalent objects not equivalent?", __LINE__ );
            testFramework.assert( Compare != LessThanFSecond, "GPSWeekZCount operator !=, Are non-equivalent objects not equivalent?", __LINE__ );
            testFramework.assert( !(Compare != Compare),      "GPSWeekZCount operator !=, Are equivalent objects not equivalent?",     __LINE__ );

            //----------------------------------------
            // Operator <
            //----------------------------------------
            testFramework.changeSourceMethod( "Operator <" );
            testFramework.assert( LessThanDay < Compare,        "Does the < operator function when left_object < right_object?",            __LINE__ );
            testFramework.assert( LessThanSecond < Compare,     "Does the < operator function when left_object < right_object by days?",    __LINE__ );
            testFramework.assert( !(Compare < LessThanSecond),  "Does the < operator function when left_object > right_object by days?",    __LINE__ );
            testFramework.assert( LessThanFSecond < Compare,    "Does the < operator function when left_object < right_object by seconds?", __LINE__ );
            testFramework.assert( !(Compare < LessThanFSecond), "Does the < operator function when left_object > right_object by seconds?", __LINE__ );
            testFramework.assert( !(Compare < CompareCopy),     "Does the < operator function when left_object = right_object?",            __LINE__ );

            //----------------------------------------
            // Greater than assertions
            //----------------------------------------
            testFramework.changeSourceMethod( "Operator >" );
            testFramework.assert( Compare > LessThanDay,        "Does the > operator function when left_object > right_object by years?",   __LINE__ );
            testFramework.assert( !(LessThanDay > Compare),     "Does the > operator function when left_object < right_object by years?",   __LINE__ );
            testFramework.assert( Compare > LessThanSecond,     "Does the > operator function when left_object > right_object by days?",    __LINE__ );
            testFramework.assert( !(LessThanSecond > Compare),  "Does the > operator function when left_object < right_object by days?",    __LINE__ );
            testFramework.assert( Compare > LessThanFSecond,    "Does the > operator function when left_object > right_object by seconds?", __LINE__ );
            testFramework.assert( !(LessThanFSecond > Compare), "Does the > operator function when left_object < right_object by seconds?", __LINE__ );
            testFramework.assert( !(Compare > CompareCopy),     "Does the > operator function when left_object = right_object?",            __LINE__ );

            //----------------------------------------
            // Less than equals assertion
            //----------------------------------------
            testFramework.changeSourceMethod( "Operator <=" );
            testFramework.assert( LessThanDay <= Compare,        "Does the < operator function when left_object < right_object by years?",    __LINE__ );
            testFramework.assert( !(Compare <= LessThanDay),     "Does the <= operator function when left_object > right_object by years?",   __LINE__ );
            testFramework.assert( LessThanSecond <= Compare,     "Does the <= operator function when left_object < right_object by days?",    __LINE__ );
            testFramework.assert( !(Compare <= LessThanSecond),  "Does the <= operator function when left_object > right_object by days?",    __LINE__ );
            testFramework.assert( LessThanFSecond <= Compare,    "Does the <= operator function when left_object < right_object by seconds?", __LINE__ );
            testFramework.assert( !(Compare <= LessThanFSecond), "Does the <= operator function when left_object > right_object by seconds?", __LINE__ );
            testFramework.assert( Compare <= CompareCopy,        "Does the <= operator function when left_object = right_object?",            __LINE__ );

            //----------------------------------------
            // Greater than equals assertion
            //----------------------------------------
            testFramework.changeSourceMethod( "Operator >=" );
            testFramework.assert( Compare >= LessThanDay,        "Does the >= operator function when left_object > right_object by years?",   __LINE__ );
            testFramework.assert( !(LessThanDay >= Compare),     "Does the >= operator function when left_object < right_object by years?",   __LINE__ );
            testFramework.assert( Compare >= LessThanSecond,     "Does the >= operator function when left_object > right_object by days?",    __LINE__ );
            testFramework.assert( !(LessThanSecond >= Compare),  "Does the >= operator function when left_object < right_object by days?",    __LINE__ );
            testFramework.assert( Compare >= LessThanFSecond,    "Does the >= operator function when left_object > right_object by seconds?", __LINE__ );
            testFramework.assert( !(LessThanFSecond >= Compare), "Does the >= operator function when left_object < right_object by seconds?", __LINE__ );
            // typo from last guy??
            testFramework.assert( !(Compare < CompareCopy),      "Does the >  operator function when left_object = right_object?",            __LINE__ );

            //----------------------------------------
            // The End!
            //----------------------------------------
            return testFramework.countFails();
        }
开发者ID:vestuto,项目名称:GPSTk,代码行数:82,代码来源:CommonTime_T.cpp

示例15: improperSetTest

        //============================================================
        // Test Suite: improperSetTest()
        //============================================================
        //
        //  Test to see if setting improper values induces the
        //  correct exception handling.
        //============================================================
        int improperSetTest( void )
        {
            CommonTime Test;
            Test.set (700000, 0, 0.);

            TestUtil testFramework( "CommonTime", "set", __FILE__, __LINE__ );

            // Break the input in various ways and make sure the proper exception is called

            //----------------------------------------
            // Does CommonTime.set() work with negative days?
            //----------------------------------------
            try
            {
                Test.set(-1,0,0.);
                testFramework.assert( false, "[testing] CommonTime.set() with negative day, [expected] exception gpstk::Exception, [actual] threw no exception", __LINE__ );
            }
            // QUESTION: Why test for gpstk::InvalidRequest exception instead of gpstk::Exception?
            // ANSWER: gpstk::InvalidRequest is a child of gpstk::Exception, and depending on CommonTime.cpp
            // we might sometimes need to be more specific than catching gpstk::Exception
            //     catch( gpstk::InvalidParameter e)
            // For now, I'm replacing gpstk::InvalidParameter with gpstk::Exception to be consistent throughout this test application
            catch( gpstk::Exception e)
            {
                testFramework.assert( true, "[expected] CommonTime.set() with negative day should throw a gpstk::Exception", __LINE__ );
            }
            catch(...)
            {
                testFramework.assert( false, "[testing] CommonTime.set() with negative day, [expected] exception gpstk::Exception, [actual] threw wrong exception", __LINE__ );
            }

            //----------------------------------------
            // Does CommonTime.set() work with too many days?
            //----------------------------------------
            try
            {
                Test.set(3442449,0,0.);
                testFramework.assert( false, "[testing] CommonTime.set() with too many days, [expected] exception gpstk::Exception, [actual] threw no exception", __LINE__ );
            }
            catch(gpstk::Exception e)
            {
                testFramework.assert( true, "[expected] CommonTime.set() with too many days should throw a gpstk::Exception", __LINE__  );
            }
            catch (...)
            {
                testFramework.assert( false, "[testing] CommonTime.set() with too many days, [expected] exception gpstk::Exception, [actual] threw wrong exception", __LINE__ );
            }

            //----------------------------------------
            // Does CommonTime.set() work with negative seconds?
            //----------------------------------------
            try
            {
                Test.set(700000,-1,0.);
                testFramework.assert( false, "[testing] CommonTime.set() with negative seconds, [expected] exception gpstk::Exception, [actual] threw no exception", __LINE__ );
            }
            catch(gpstk::Exception e)
            {
                testFramework.assert( true, "[expected] CommonTime.set() with negative seconds should throw a gpstk::Exception", __LINE__ );
            }
            catch (...)
            {
                testFramework.assert( false, "Fail", __LINE__ );
            }

            //----------------------------------------
            // Does a set method work with too many seconds?
            //----------------------------------------
            try
            {
                Test.set(700000,24*60*60+1,0.);
                testFramework.assert( false, "[testing] CommonTime.set() with too many seconds, [expected] exception gpstk::Exception, [actual] threw no exception", __LINE__ );
            }
            catch(gpstk::Exception e)
            {
                testFramework.assert( true, "[expected] CommonTime.set() with too many seconds should throw a gpstk::Exception", __LINE__ );
            }
            catch (...)
            {
                testFramework.assert( false, "[testing] CommonTime.set() with too many seconds, [expected] exception gpstk::Exception, [actual] threw wrong exception", __LINE__ );
            }

            //----------------------------------------
            // Does a set method work with negative fractional seconds?
            //----------------------------------------
            try
            {
                Test.set(700000,0,-1.);
                testFramework.assert( false, "[testing] CommonTime.set() with negative fractional seconds, [expected] exception gpstk::Exception, [actual] threw no exception", __LINE__ );
            }
            catch(gpstk::Exception e)
            {
                testFramework.assert( true, "[expected] CommonTime.set() with negative fractional seconds should throw a gpstk::Exception", __LINE__ );
//.........这里部分代码省略.........
开发者ID:vestuto,项目名称:GPSTk,代码行数:101,代码来源:CommonTime_T.cpp


注:本文中的CommonTime类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。