Ejemplo n.º 1
0
//==========================================================================================================================
// initializationTest ensures the constructors set the values properly
//==========================================================================================================================
   int initializationTest(void)
   {
      gpstk::TestUtil testFramework( "SatID", "Constructor", __FILE__, __LINE__);

      gpstk::SatID Compare1(5, gpstk::SatID::SatelliteSystem (1));
      testFramework.assert(Compare1.id == 5,
                           "Explicit constructor did not set the correct id value", __LINE__);
      testFramework.assert(Compare1.system == gpstk::SatID::SatelliteSystem(1),
                           "Explicit constructor did not set the correct SatelliteSystem", __LINE__);


      gpstk::SatID Compare2(0, gpstk::SatID::SatelliteSystem (12));
      testFramework.assert(Compare2.id == 0,
                           "Explicit constructor did not set the correct id value", __LINE__);
      testFramework.assert(Compare2.system == gpstk::SatID::SatelliteSystem(12),
                           "Explicit constructor did not set the correct SatelliteSystem", __LINE__);


      gpstk::SatID Compare3(-1, gpstk::SatID::SatelliteSystem (-1));
      testFramework.assert(Compare3.id == -1,
                           "Explicit constructor did not set the correct id value", __LINE__);
      testFramework.assert(Compare3.system == gpstk::SatID::SatelliteSystem(-1),
                           "Explicit constructor did not set the correct SatelliteSystem", __LINE__);

      return testFramework.countFails();
   }
Ejemplo n.º 2
0
//==========================================================================================================================
//	Test to check that the correct solution is found. 
//	The result should be only a 3rd order term.
//==========================================================================================================================
		int SolutionTest3rdOrderResult()
		{
			TestUtil testFramework( "PolyFit", "Solution", __FILE__, __LINE__ );
			std::string failMesg;

			int n = 4; //Highest order in polynomial fit + 1 (constant term)
			int errorCounter = 0;
			gpstk::PolyFit<double> test(n); 
			gpstk::Vector<double> soln; // To store the solution
			// Data values to create the fit
			double indep[6] = {0, 1, 2, 3, 4, 5}, dep[6] = {0, 1, 8, 27, 64, 125};
                        // Add the data to the PolyFit object
			for(int i=0; i<6; i++)
			{
				test.Add(dep[i],indep[i]);
			}
			// Store the solution
			soln = test.Solution();
			//std::cout << "Solution is: " << soln << std::endl;
			for (int i = 0; i<4; i++) // Loop over the solution values
			{

				// Make sure the data matches what is expected
				// Expect soln = {0, 0, 0, 1}
				if ((i != 3 && fabs(soln[i]) > eps) || (i == 3 && abs(soln[i] - 1) > eps))
				{
					//std::cout << "i: " << i << " value: " << soln[i] << " absVal: " << fabs(soln[i]) << " fabsVal(soln-1): " << fabs(soln[i]-1) << std::endl; 
					errorCounter += 1; // Increment the return value for each wrong value
				}
			}
			failMesg = "Was the solution computed correct?";
			testFramework.assert(errorCounter == 0, failMesg, __LINE__);

			return testFramework.countFails(); // Return the result of the test.
		}
Ejemplo n.º 3
0
	int operatorTest(void)
	{
		TestUtil testFramework("ObsID", "== Operator", __FILE__, __LINE__);
		std::string failMesg;

		gpstk::ObsID Compare1(gpstk::ObsID::otRange, gpstk::ObsID::cbL1, gpstk::ObsID::tcCA);
		gpstk::ObsID Compare2(gpstk::ObsID::otRange, gpstk::ObsID::cbL1, gpstk::ObsID::tcCA);
		gpstk::ObsID Compare3(gpstk::ObsID::otDoppler, gpstk::ObsID::cbL1, gpstk::ObsID::tcCA);		

		failMesg = "Are equivalent objects equivalent?";
		testFramework.assert(Compare1 == Compare2, failMesg, __LINE__);

		failMesg = "Are non-equivalent objects equivalent?";
		testFramework.assert(!(Compare1 == Compare3), failMesg, __LINE__);

		testFramework.changeSourceMethod("!= Operator");

		failMesg = "Are non-equivalent objects not equivalent?";
		testFramework.assert(Compare1 != Compare3, failMesg, __LINE__);

		failMesg = "Are equivalent objects not equivalent?";
		testFramework.assert(!(Compare1 != Compare2), failMesg, __LINE__);

		return testFramework.countFails();
	}
Ejemplo n.º 4
0
//==========================================================================================================================
//	Test to check that the correct solution is found.
//==========================================================================================================================
		int SolutionTest()
		{
			TestUtil testFramework( "PolyFit", "Solution", __FILE__, __LINE__ );
			std::string failMesg;

			int n = 4;
			int errorCounter = 0;
			gpstk::PolyFit<double> test(n);
			gpstk::Vector<double> soln;
			double indep[6] = {0, 1, 2, 3, 4, 5}, dep[6] = {2, 8, 30, 80, 170, 312};

			for(int i=0; i<6; i++)
			{
				test.Add(dep[i],indep[i]);
			}


			soln = test.Solution();
			//std::cout << "Solution is: " << soln << std::endl;		
			for (int i = 0; i<4; i++)
			{
				// Make sure the data matches what is expected
				// Expect soln = {2, 2, 2, 2}
				if (fabs(soln[i] - 2) > eps)
				{
					//std::cout << "i: " << i << " value: " << soln[i] << " absVal: " << fabs(soln[i]) << " fabs(val-2): " << fabs(soln[i] - 2) << std::endl; 
					errorCounter += 1; // Increment the return value for each wrong value
				}
			}

			failMesg = "Was the solution computed correct?";
			testFramework.assert(errorCounter==0, failMesg, __LINE__);

			return testFramework.countFails(); // Return the result of the test.
		}
Ejemplo n.º 5
0
   int getLeapSecondsTest(void)
   {
      gpstk::TestUtil testFramework("TimeSystem", "Leap Seconds", __FILE__, __LINE__);
      std::string testMesg;

      gpstk::TimeSystem Compare(1);

         //-------------------------------------------------------------------------
         //Check leap-second computation prior to 1972 but not before 1960
         //-------------------------------------------------------------------------
      testMesg = "Incorrect value returned for getLeapSeconds";

         //Should be (inputDate - lastRefDate) * rate + leapSeconds
         //4.213170+488*0.002592
      testFramework.assert(std::abs(Compare.getLeapSeconds(1969, 6, 3) - 5.478066) < eps, testMesg, __LINE__);
         //1.8458580 + 118*0.0011232
      testFramework.assert(std::abs(Compare.getLeapSeconds(1962, 4,  29) - 1.9783956) < eps, testMesg, __LINE__);
         //3.6401300 + 5*.001296
      testFramework.assert(std::abs(Compare.getLeapSeconds(1965, 3,  6) - 3.64661) < eps, testMesg, __LINE__);
         //4.2131700 + 295*.002592
      testFramework.assert(std::abs(Compare.getLeapSeconds(1968, 11,  22) - 4.97781) < eps, testMesg, __LINE__);
         //4.3131700 + 409*.002592
      testFramework.assert(std::abs(Compare.getLeapSeconds(1967, 2,  14) - 5.373298) < eps, testMesg, __LINE__);

         //-------------------------------------------------------------------------
         //Check leap-second computation after 1/1/1972
         //-------------------------------------------------------------------------
      testFramework.assert(std::abs(Compare.getLeapSeconds(1995, 10, 13) - 29) < eps, testMesg, __LINE__);
      testFramework.assert(std::abs(Compare.getLeapSeconds(2004, 3, 25) - 32) < eps, testMesg, __LINE__); 
      testFramework.assert(std::abs(Compare.getLeapSeconds(1984, 8, 27) - 22) < eps, testMesg, __LINE__);
      testFramework.assert(std::abs(Compare.getLeapSeconds(1972, 5, 8) - 10) < eps, testMesg, __LINE__);


      return testFramework.countFails();
   }
Ejemplo n.º 6
0
	int initialization(void)
	{		
		TestUtil testFramework("ObsID", "Default Constructor", __FILE__, __LINE__);
		std::string failMesg;

		gpstk::ObsID empty;

		failMesg = "Did the default constructor assign the right type value?";
		testFramework.assert(empty.type == gpstk::ObsID::otUnknown, failMesg, __LINE__);

		failMesg = "Did the default constructor assign the right band value?";
		testFramework.assert(empty.band == gpstk::ObsID::cbUnknown, failMesg, __LINE__);

		failMesg = "Did the default constructor assign the right code value?";
		testFramework.assert(empty.code == gpstk::ObsID::tcUnknown, failMesg, __LINE__);	

		testFramework.changeSourceMethod("Explicit Constructor");

		gpstk::ObsID Compare(gpstk::ObsID::otRange, gpstk::ObsID::cbL1, gpstk::ObsID::tcCA);

		failMesg = "Did the explicit constructor assign the right type value?";
		testFramework.assert(Compare.type == gpstk::ObsID::otRange, failMesg, __LINE__);

		failMesg = "Did the explicit constructor assign the right band value?";
		testFramework.assert(Compare.band == gpstk::ObsID::cbL1, failMesg, __LINE__);

		failMesg = "Did the explicit constructor assign the right code value?";
		testFramework.assert(Compare.code == gpstk::ObsID::tcCA, failMesg, __LINE__);

		return testFramework.countFails();
	}
Ejemplo n.º 7
0
//==========================================================================================================================
//	Test to check that the correct solution is found. 
//	In this case the problem is singular.
//==========================================================================================================================
		int SolutionFailTest()
		{
			TestUtil testFramework( "PolyFit", "Solution", __FILE__, __LINE__ );
			std::string failMesg;

			int n = 4;
			gpstk::PolyFit<double> test(n);
			gpstk::Vector<double> soln;
			// Set the independent variable to the same value
			double indep[6] = {1, 1, 1, 1, 1, 1}, dep[6] = {1, 2, 3, 4, 5, 6};

			for(int i=0; i<6; i++)
			{
				test.Add(dep[i],indep[i]);
			}

			soln = test.Solution(); // This might NaN

			//std::cout << "Solution is: " << test.isSingular() << std::endl;		

			failMesg = "Was the solution computed singular?";
			testFramework.assert(test.isSingular(), failMesg, __LINE__); // The singular flag should be set

			return testFramework.countFails();
		}
Ejemplo n.º 8
0
   int methodTest(void)
   {
      gpstk::TestUtil testFramework( "ValidType", "Various Methods", __FILE__, __LINE__ );
      std::string failMesg;

      gpstk::ValidType<float> vfloat0;

      failMesg = "Is the invalid Valid object set as valid?";
      testFramework.assert(!vfloat0.is_valid(), failMesg, __LINE__);

      failMesg = "Is the invalid Valid object's value 0?";
      testFramework.assert(std::abs(vfloat0.get_value()) < eps, failMesg, __LINE__);

      gpstk::ValidType<float> vfloat (5);

      failMesg = "Does the get_value method return the correct value?";
      testFramework.assert(vfloat.get_value() == 5, failMesg, __LINE__);

      failMesg = "Is the valid Valid object set as valid?";
      testFramework.assert(vfloat.is_valid(), failMesg, __LINE__);

      vfloat.set_valid(false);

      failMesg = "Was the valid Valid object correctly set to invalid?";
      testFramework.assert(!vfloat.is_valid(), failMesg, __LINE__);

      return testFramework.countFails();
   }
Ejemplo n.º 9
0
//==========================================================================================================================
// asStringTest checks that a SatID object can be reported as a string
//==========================================================================================================================
   int asStringTest(void)
   {
      gpstk::TestUtil testFramework( "SatID", "asStringTest", __FILE__, __LINE__);


      std::string compareString1,compareString2,compareString3;

         //---------------------------------------------------------------------
         //Output for GPS satellite and single digit ID
         //---------------------------------------------------------------------
      gpstk::SatID sat1(5, gpstk::SatID::SatelliteSystem (1));
      compareString1 = "GPS 5";
      testFramework.assert(gpstk::StringUtils::asString(sat1) == compareString1,
                           "asString did not produce the expected result", __LINE__);


         //---------------------------------------------------------------------
         //Output for invalid UserDefined satellite and triple digit ID
         //---------------------------------------------------------------------
      gpstk::SatID sat2(110, gpstk::SatID::SatelliteSystem (10));
      compareString2 = "UserDefined 110";
      testFramework.assert(gpstk::StringUtils::asString(sat2) == compareString2,
                           "asString did not produce the expected result", __LINE__);


         //---------------------------------------------------------------------
         //Output for invalid satellite and negative ID
         //---------------------------------------------------------------------
      gpstk::SatID sat3(-10, gpstk::SatID::SatelliteSystem (50));
      compareString3 = "?? -10";
      testFramework.assert(gpstk::StringUtils::asString(sat3) == compareString3,
                           "asString did not produce the expected result", __LINE__);

      return testFramework.countFails();
   }
Ejemplo n.º 10
0
//==========================================================================================================================
//	Test to verify the evaluate method with a single input.
//==========================================================================================================================
		int EvaluateTest()
		{
			TestUtil testFramework( "PolyFit", "Evaluate", __FILE__, __LINE__ );
			std::string failMesg;

			int n = 4;
			gpstk::PolyFit<double> test(n);
			double soln, eval;
			double indep[6] = {0, 1, 2, 3, 4, 5}, dep[6] = {0, 1, 4, 9, 16, 25};

			eval = 6;
			
			for(int i=0; i<6; i++)
			{
				test.Add(dep[i],indep[i]);
			}


			soln = test.Evaluate(eval);

			failMesg = "Was the solution computed correct?";
			testFramework.assert(fabs(soln - eval*eval) < eps, failMesg, __LINE__);

			return testFramework.countFails();
		}
Ejemplo n.º 11
0
int Matrix_T::transposeTest(void)
{
	TestUtil testFramework("Matrix", "Transpose", __FILE__, __LINE__);

	gpstk::Matrix<double> A1T(2,2),A2T(3,3),A3T(4,4),A4T(4,5);
	gpstk::Matrix<double> CompareA1T(2,2),CompareA2T(3,3),CompareA3T(4,4),CompareA4T(5,4);
	A1T = gpstk::transpose(A1);
	A2T = gpstk::transpose(A2);
	A3T = gpstk::transpose(A3);
	A4T = gpstk::transpose(A4);

	double temp4[4] = {2,-3,5,-7};
	double temp5[9] = {1,3,-5,0,1,-1,-2,-2,9};
	double temp6[16] = {2,1,0,0,3,0,2,2,1,3,-3,3,5,1,2,1};
	double temp7[20] = {8,7,1,-78,5,-9,7,24,18,5,10,20,-2,0,11,-68,1.5,7,47,0};		

	CompareA1T = temp4;
	CompareA2T = temp5;
	CompareA3T = temp6;
	CompareA4T = temp7;

	int badCount = 0;

	//testFramework.assert(AT == CompareAT, testMesg, __LINE__);
	for(int i = 0; i < A1T.rows(); i++)
		for(int j = 0; j < A1T.cols(); j++)
     			if (A1T(i,j) != CompareA1T(i,j)) {badCount++;}
	failDescriptionStream << "Check if gpstk::transpose(A1) returns the right matrix. " << badCount << " of the elements are incorrect.";
	failDescriptionString = failDescriptionStream.str(); failDescriptionStream.str("");
    testFramework.assert(badCount==0, failDescriptionString, __LINE__);
  	badCount = 0; // Reset error counter

	for(int i = 0; i < A2T.rows(); i++)
		for(int j = 0; j < A2T.cols(); j++)
     			if (A2T(i,j) != CompareA2T(i,j)) {badCount++;}
	failDescriptionStream << "Check if gpstk::transpose(A2) returns the right matrix. " << badCount << " of the elements are incorrect.";
	failDescriptionString = failDescriptionStream.str(); failDescriptionStream.str("");
    testFramework.assert(badCount==0, failDescriptionString, __LINE__);
  	badCount = 0; // Reset error counter

	for(int i = 0; i < A3T.rows(); i++)
		for(int j = 0; j < A3T.cols(); j++)
     			if (A3T(i,j) != CompareA3T(i,j)) {badCount++;}
	failDescriptionStream << "Check if gpstk::transpose(A3) returns the right matrix. " << badCount << " of the elements are incorrect.";
	failDescriptionString = failDescriptionStream.str(); failDescriptionStream.str("");
    testFramework.assert(badCount==0, failDescriptionString, __LINE__);
  	badCount = 0; // Reset error counter

	for(int i = 0; i < A4T.rows(); i++)
		for(int j = 0; j < A4T.cols(); j++)
     			if (A4T(i,j) != CompareA4T(i,j)) {badCount++;}
	failDescriptionStream << "Check if gpstk::transpose(A4) returns the right matrix. " << badCount << " of the elements are incorrect.";
	failDescriptionString = failDescriptionStream.str(); failDescriptionStream.str("");
    testFramework.assert(badCount==0, failDescriptionString, __LINE__);
  	badCount = 0; // Reset error counter      	

  	return testFramework.countFails();
  }
Ejemplo n.º 12
0
   int correctionTest(void)
   {
      gpstk::TestUtil testFramework("TimeSystem", "Correction", __FILE__, __LINE__);
      std::string testMesg;

      gpstk::TimeSystem GPStime(2);
      gpstk::TimeSystem GLOtime(3);
      gpstk::TimeSystem GALtime(4);
      gpstk::TimeSystem QZStime(5);
      gpstk::TimeSystem BDTtime(6);
      gpstk::TimeSystem UTCtime(7);
      gpstk::TimeSystem TAItime(8);
      gpstk::TimeSystem TTtime(9);
      gpstk::TimeSystem TDBtime(10);


         //-------------------------------------------------------------------------
         //Check conversion from any given time system to UTC and back 
         //-------------------------------------------------------------------------
      testMesg = "Conversion from UTC time to GPS time was incorrect";
      testFramework.assert(std::abs(gpstk::TimeSystem::Correction(UTCtime, GPStime, 1990, 11, 6) - 6) < eps, testMesg, __LINE__);
      testMesg = "Conversion from GPS time to UTC time was incorrect";
      testFramework.assert(std::abs(gpstk::TimeSystem::Correction(GPStime, UTCtime, 2004, 11, 16) + 13) < eps, testMesg, __LINE__);		
      testMesg = "Conversion from UTC time to GLO time was incorrect";
      testFramework.assert(std::abs(gpstk::TimeSystem::Correction(UTCtime, GLOtime, 1992, 10, 3) - 0) < eps, testMesg, __LINE__);
      testMesg = "Conversion from GLO time to UTC time was incorrect";
      testFramework.assert(std::abs(gpstk::TimeSystem::Correction(GLOtime, UTCtime, 1995, 5, 10) - 0) < eps, testMesg, __LINE__);
      testMesg = "Conversion from UTC time to GAL time was incorrect";
      testFramework.assert(std::abs(gpstk::TimeSystem::Correction(UTCtime, GALtime, 1997, 7, 25) - 12) < eps, testMesg, __LINE__);
      testMesg = "Conversion from GAL time to UTC time was incorrect";
      testFramework.assert(std::abs(gpstk::TimeSystem::Correction(GALtime, UTCtime, 2008, 6, 5) + 14) < eps, testMesg, __LINE__);
		
         // QZSS can't be converted 
         //testMesg = "Conversion from UTC time to QZS time was incorrect";
         //testFramework.assert(std::abs(gpstk::TimeSystem::Correction(UTCtime, QZStime, 1985, 8, 10) - 4) < eps, testMesg, __LINE__);
         //testMesg = "Conversion from QZS time to UTC time was incorrect";
         //testFramework.assert(std::abs(gpstk::TimeSystem::Correction(QZStime, UTCtime, 2010, 2, 14) - 15) < eps, testMesg, __LINE__);
		
      testMesg = "Conversion from UTC time to BDT time was incorrect";
      testFramework.assert(std::abs(gpstk::TimeSystem::Correction(UTCtime, BDTtime, 2001, 9, 21) - 0) < eps, testMesg, __LINE__);
      testMesg = "Conversion from BDT time to UTC time was incorrect";
      testFramework.assert(std::abs(gpstk::TimeSystem::Correction(BDTtime, UTCtime, 2012, 8, 27) - 0) < eps, testMesg, __LINE__);
      testMesg = "Conversion from UTC time to TAI time was incorrect";
      testFramework.assert(std::abs(gpstk::TimeSystem::Correction(UTCtime, TAItime, 2014, 6, 1) - 35) < eps, testMesg, __LINE__);
      testMesg = "Conversion from TAI time to UTC time was incorrect";
      testFramework.assert(std::abs(gpstk::TimeSystem::Correction(TAItime, UTCtime, 2015, 1, 1) + 35) < eps, testMesg, __LINE__);	
      testMesg = "Conversion from UTC time to TT time was incorrect";
      testFramework.assert(std::abs(gpstk::TimeSystem::Correction(UTCtime,  TTtime, 2005, 4, 31) - (13 + 51.184)) < eps, testMesg, __LINE__);
      testMesg = "Conversion from TT time to UTC time was incorrect";
      testFramework.assert(std::abs(gpstk::TimeSystem::Correction(TTtime, UTCtime, 1990, 7, 21) + (6 + 51.184) ) < eps, testMesg, __LINE__);
         //reference section B of astronomical almanac for TDB conversion
      testMesg = "Conversion from UTC time to TDB time was incorrect";
      testFramework.assert(std::abs(gpstk::TimeSystem::Correction(UTCtime,  TDBtime, 2007, 12, 25) - 65.1840299405112091335467994213104248046875) < eps, testMesg, __LINE__);
      testMesg = "Conversion from TDB time to UTC time was incorrect";
      testFramework.assert(std::abs(gpstk::TimeSystem::Correction(TDBtime, UTCtime, 1991, 4, 25) + 58.1838658094272460630236309953033924102783203125) < eps, testMesg, __LINE__);

      return testFramework.countFails();
   }
Ejemplo n.º 13
0
//==========================================================================================================================
// dumpTest checks the output from SatID::dump meets its expectations
//==========================================================================================================================
   int dumpTest(void)
   {
      gpstk::TestUtil testFramework( "SatID", "dump(std::stream)", __FILE__, __LINE__);


         //---------------------------------------------------------------------
         //Output for GPS satellite and single digit ID
         //---------------------------------------------------------------------
      gpstk::SatID sat1(5, gpstk::SatID::SatelliteSystem (1));
      std::string outputString1, compareString1;
      std::stringstream outputStream1;

      sat1.dump(outputStream1);
      outputString1 = outputStream1.str();
      compareString1 = "GPS 5";

      testFramework.assert(outputString1 == compareString1,
                           "dump did not output the expected response", __LINE__);


         //---------------------------------------------------------------------
         //Output for invalid UserDefined satellite and triple digit ID
         //---------------------------------------------------------------------
      gpstk::SatID sat2(110, gpstk::SatID::SatelliteSystem (10));
      std::string outputString2, compareString2;
      std::stringstream outputStream2;

      sat2.dump(outputStream2);
      outputString2 = outputStream2.str();
      compareString2 = "UserDefined 110";

      testFramework.assert(outputString2 == compareString2,
                           "dump did not output the expected response", __LINE__);

         //---------------------------------------------------------------------
         //Output for invalid satellite and negative ID
         //---------------------------------------------------------------------
      gpstk::SatID sat3(-10, gpstk::SatID::SatelliteSystem (50));
      std::string outputString3, compareString3;
      std::stringstream outputStream3;

      sat3.dump(outputStream3);
      outputString3 = outputStream3.str();
      compareString3 = "?? -10";

      testFramework.assert(outputString3 == compareString3,
                           "dump did not output the expected response", __LINE__);

      return testFramework.countFails();

   }
Ejemplo n.º 14
0
	//reads in 3-4 length string
	int fromStringConstructorTest(void)
	{
		TestUtil testFramework("ObsID", "Constructor from String", __FILE__, __LINE__);
		std::string failMesg;

		//set with invalid length
		failMesg = "[testing] ObsID constructor from invalid string, [expected] exception gpstk::Exception, [actual] threw no exception";		
		try{gpstk::ObsID invalidID("G 10 "); testFramework.assert(false, failMesg, __LINE__);}
		catch (gpstk::Exception e) {testFramework.assert(true, failMesg, __LINE__);}

		try{gpstk::ObsID invalidID("G1"); testFramework.assert(false, failMesg, __LINE__);}
		catch (gpstk::Exception e) {testFramework.assert(true, failMesg, __LINE__);}

		//testing base assign w/out using any of the reused codes
		gpstk::ObsID obs1("GC1C"); // GPS L1 C/A PseudoRange

		failMesg = "Was the type value stored correctly?";
		testFramework.assert(obs1.type == gpstk::ObsID::otRange, failMesg, __LINE__);

		failMesg = "Was the band value stored correctly?";
		testFramework.assert(obs1.band == gpstk::ObsID::cbL1, failMesg, __LINE__);

		failMesg = "Was the code value stored correctly?";
		testFramework.assert(obs1.code == gpstk::ObsID::tcCA, failMesg, __LINE__);

		//testing only case of reassinged codes for GPS
		gpstk::ObsID obs2("GD5X"); // GPS L5 IQ Doppler

		failMesg = "Was the type value stored correctly?";
		testFramework.assert(obs2.type == gpstk::ObsID::otDoppler, failMesg, __LINE__);

		failMesg = "Was the band value stored correctly?";
		testFramework.assert(obs2.band == gpstk::ObsID::cbL5, failMesg, __LINE__);

		failMesg = "Was the code value stored correctly?";
		testFramework.assert(obs2.code == gpstk::ObsID::tcIQ5, failMesg, __LINE__);

		//testing completely random case
		gpstk::ObsID obs3("JL6L"); // QZSS E6 L Carrier Phase

		failMesg = "Was the type value stored correctly?";
		testFramework.assert(obs3.type == gpstk::ObsID::otPhase, failMesg, __LINE__);

		failMesg = "Was the band value stored correctly?";
		testFramework.assert(obs3.band == gpstk::ObsID::cbE6, failMesg, __LINE__);

		failMesg = "Was the code value stored correctly?";
		testFramework.assert(obs3.code == gpstk::ObsID::tcJQ6, failMesg, __LINE__);

		return testFramework.countFails();
	}
Ejemplo n.º 15
0
int Matrix_T::solutionTest(void)
{
	TestUtil testFramework("Matrix", "Solution", __FILE__, __LINE__);

//Solution via Ainv*B, DEPENDENT ON INVERSE FUNCTION
//Is there another way to solve the system? Need to find A4sol still
	gpstk::Vector<double> A1sol(2), A2sol(3), A3sol(4);

	gpstk::Vector<double> CompareA1sol(2), CompareA2sol(3), CompareA3sol(4);

	A1sol = gpstk::inverse(A1) * B1;
	A2sol = gpstk::inverse(A2) * B2;
	A3sol = gpstk::inverse(A3) * B3;
	double temp8[2]= {-45,19};
	double temp9[3]= {17./3,-31./3,7./3};
	double temp10[4]= {-132,-65,15,89};
	CompareA1sol = temp8;
	CompareA2sol = temp9;
	CompareA3sol = temp10;

	int badCount = 0;

	//testFramework.assert(Asol == CompareAsol, failDescriptionString, __LINE__);
    for(int i = 0; i < A1sol.size(); i++)
    {
 	failMesg = "The solution calculated from A1inverse * b is incorrect";
    if (std::abs(CompareA1sol[i] - A1sol[i]) > eps) {badCount++;} //sizes mismatch, check till v1 ends
  	}
  	testFramework.assert(badCount==0, failMesg, __LINE__);
  	badCount = 0; // Reset error counter

    for(int i = 0; i < A2sol.size(); i++)
    {
 	failMesg = "The solution calculated from A2inverse * b is incorrect";
    if (std::abs(CompareA2sol[i] - A2sol[i]) > eps) {badCount++;} //sizes mismatch, check till v1 ends
  	}
  	testFramework.assert(badCount==0, failMesg, __LINE__);
  	badCount = 0; // Reset error counter

    for(int i = 0; i < A3sol.size(); i++)
    {
 	failMesg = "The solution calculated from A3inverse * b is incorrect";
    if (std::abs(CompareA3sol[i] - A3sol[i]) > eps) {badCount++; std::cout<<(CompareA3sol[i]-A3sol[i])<<std::endl;} //sizes mismatch, check till v1 ends
  	}
  	testFramework.assert(badCount==0, failMesg, __LINE__);
  	badCount = 0; // Reset error counter

  	return testFramework.countFails();
}
Ejemplo n.º 16
0
int Matrix_T::inverseTest(void)
{
	TestUtil testFramework("Matrix", "Inverse", __FILE__, __LINE__);

	gpstk::Matrix<double> A1inv(2,2),A2inv(3,3),A3inv(4,4),A4inv(3,4);
	gpstk::Matrix<double> CompareA1inv(2,2),CompareA2inv(3,3),CompareA3inv(4,4),CompareA4inv(3,4);
	A1inv = gpstk::inverse(A1);
	A2inv = gpstk::inverse(A2);
	A3inv = gpstk::inverse(A3);
	try{A4inv = gpstk::inverse(A4); testFramework.assert(false, failMesg, __LINE__);}
	catch(gpstk::Exception e) {testFramework.assert(true, failMesg, __LINE__);}

	double temp1[4] = {-7,-5,3,2};
	double temp2[9] = {7./3,2./3,2./3,-17./3,-1./3,-4./3,2./3,1./3,1./3};
	double temp3[16] = {18, -35, -28, 1, 9, -18, -14, 1, -2, 4, 3, 0, -12, 24, 19, -1};

	CompareA1inv = temp1;
	CompareA2inv = temp2;
	CompareA3inv = temp3;

	int badCount = 0;

	//testFramework.assert(Ainv == CompareAinv, testMesg, __LINE__);
	for(int i = 0; i < A1inv.rows(); i++)
		for(int j = 0; j < A1inv.cols(); j++)
     			if (std::abs(A1inv(i,j) - CompareA1inv(i,j)) > eps) {badCount++;}
	failDescriptionStream << "Check if gpstk::inverse(A1) returns the right matrix. " << badCount << " of the elements are incorrect.";
	failDescriptionString = failDescriptionStream.str(); failDescriptionStream.str("");
    testFramework.assert(badCount==0, failDescriptionString, __LINE__);
  	badCount = 0; // Reset error counter

	for(int i = 0; i < A2inv.rows(); i++)
		for(int j = 0; j < A2inv.cols(); j++)
     			if (std::abs(A2inv(i,j) - CompareA2inv(i,j)) > eps) {badCount++;}
	failDescriptionStream << "Check if gpstk::inverse(A2) returns the right matrix. " << badCount << " of the elements are incorrect.";
	failDescriptionString = failDescriptionStream.str(); failDescriptionStream.str("");
    testFramework.assert(badCount==0, failDescriptionString, __LINE__);
  	badCount = 0; // Reset error counter

	for(int i = 0; i < A3inv.rows(); i++)
		for(int j = 0; j < A3inv.cols(); j++)
     			if (std::abs(A3inv(i,j) - CompareA3inv(i,j)) > eps) {badCount++;}
	failDescriptionStream << "Check if gpstk::inverse(A3) returns the right matrix. " << badCount << " of the elements are incorrect.";
	failDescriptionString = failDescriptionStream.str(); failDescriptionStream.str("");
    testFramework.assert(badCount==0, failDescriptionString, __LINE__);
  	badCount = 0; // Reset error counter      	      	

  	return testFramework.countFails();
}
Ejemplo n.º 17
0
int Matrix_T::determinantTest(void)
{
	TestUtil testFramework("Matrix", "Determinant", __FILE__, __LINE__);

  	double CompareDetA1 = 1.0;
  	double CompareDetA2 = 3.0;
  	double CompareDetA3 = 1.0;

  	failMesg = "The calculated determinant is incorrect";
  	testFramework.assert(std::abs(gpstk::det(A1) - CompareDetA1) < eps, failMesg, __LINE__);
  	testFramework.assert(std::abs(gpstk::det(A2) - CompareDetA2) < eps, failMesg, __LINE__);
  	testFramework.assert(std::abs(gpstk::det(A3) - CompareDetA3) < eps, failMesg, __LINE__);

  	return testFramework.countFails();
}
Ejemplo n.º 18
0
	int asStringTest(void)
	{
		TestUtil testFramework("ObsID", "asString", __FILE__, __LINE__);
		std::string failMesg;
		gpstk::ObsID Compare(gpstk::ObsID::otPhase, gpstk::ObsID::cbE5b, gpstk::ObsID::tcIE5);

		std::string outputString, referenceString;

		outputString = gpstk::StringUtils::asString(Compare);
		referenceString = "E5b GALI5 phase";

		failMesg = "Did the asString function work correctly?";
		testFramework.assert(outputString == referenceString, failMesg, __LINE__);

		return testFramework.countFails();
	}
Ejemplo n.º 19
0
		int StdDevYTest()
		// Verify the Y Standard Deviation calculation.
		{
			TestUtil testFramework("BivarStats","StdDevY()",__FILE__,__LINE__);
			std::string failMesg;

			gpstk::BivarStats<double> test;
			test.add(1, 2);		
			test.add(2, 5);
			test.add(3, 1);
			test.add(4, 4);
			test.add(5, 3);

			failMesg  = "The stdDevY method was unsuccessful";
			//std::cout << "The Standard Deviation of Y is: " << test.stdDevY() << std::endl;
			testFramework.assert(fabs(test.stdDevY() - sqrt(2.5)) < eps, failMesg, __LINE__);
			return testFramework.countFails();
		}
Ejemplo n.º 20
0
		int ConditionalUncertaintyTest()
		// Verify the Conditional Uncertainty calculation.
		{
			TestUtil testFramework("BivarStats","ConditionalUncertaintyTest()",__FILE__,__LINE__);
			std::string failMesg;

			gpstk::BivarStats<double> test;
			test.add(1, 2);		
			test.add(2, 5);
			test.add(3, 1);
			test.add(4, 4);
			test.add(5, 3);

			failMesg  = "The sigmaYX method was unsuccessful";
			//std::cout << "The Conditional Uncertainty is: " << test.sigmaYX() << std::endl;
			testFramework.assert(fabs(test.sigmaYX() - 1.81659021245849) < eps, failMesg, __LINE__);
			return testFramework.countFails();
		}
Ejemplo n.º 21
0
		int CorrelationTest()
		// Verify the Correlation calculation.
		{
			TestUtil testFramework("BivarStats","Correlation()",__FILE__,__LINE__);
			std::string failMesg;

			gpstk::BivarStats<double> test;
			test.add(1, 2);		
			test.add(2, 5);
			test.add(3, 1);
			test.add(4, 4);
			test.add(5, 3);

			failMesg  = "The correlation method was unsuccessful";
			//std::cout << "The Correlation is: " << test.correlation() << std::endl;
			testFramework.assert(fabs(test.correlation() - 0.1) < eps, failMesg, __LINE__);
			return testFramework.countFails();
		}
Ejemplo n.º 22
0
		int AverageXTest()
		// Verify the X average calculation.
		{
			TestUtil testFramework("BivarStats","AverageX()",__FILE__,__LINE__);
			std::string failMesg;

			gpstk::BivarStats<double> test;
			test.add(1, 2);		
			test.add(2, 5);
			test.add(3, 1);
			test.add(4, 4);
			test.add(5, 3);

			failMesg  = "The AverageX method was unsuccessful";
			//std::cout << "The Average of X is: " << test.averageX() << std::endl;
			testFramework.assert(test.averageX() == 3, failMesg, __LINE__);
			return testFramework.countFails();
		}
Ejemplo n.º 23
0
		int MaxYTest()
		// Verify the Y maximum calculation.
		{
			TestUtil testFramework("BivarStats","MaximumY()",__FILE__,__LINE__);
			std::string failMesg;

			gpstk::BivarStats<double> test;
			test.add(1, 2);		
			test.add(2, 5);
			test.add(3, 1);
			test.add(4, 4);
			test.add(5, 3);

			failMesg  = "The MaximumY method was unsuccessful";
			//std::cout << "The Maximum of Y is: " << test.maximumY() << std::endl;
			testFramework.assert(test.maximumY() == 5, failMesg, __LINE__);
			return testFramework.countFails();
		}
Ejemplo n.º 24
0
		int VarianceYTest()
		// Verify the Y variance calculation.
		{
			TestUtil testFramework("BivarStats","VarianceY()",__FILE__,__LINE__);
			std::string failMesg;

			gpstk::BivarStats<double> test;
			test.add(1, 2);		
			test.add(2, 5);
			test.add(3, 1);
			test.add(4, 4);
			test.add(5, 3);

			failMesg  = "The VarianceY method was unsuccessful";
			//std::cout << "The Variance of Y is: " << test.varianceY() << std::endl;
			testFramework.assert(fabs(test.varianceY() - 2.5) < eps, failMesg, __LINE__);
			return testFramework.countFails();	
		}
Ejemplo n.º 25
0
		int SlopeUncertaintyTest()
		// Verify the Slope Uncertainty calculation.
		{
			TestUtil testFramework("BivarStats","SlopeUncertainty()",__FILE__,__LINE__);
			std::string failMesg;

			gpstk::BivarStats<double> test;
			test.add(1, 2);		
			test.add(2, 5);
			test.add(3, 1);
			test.add(4, 4);
			test.add(5, 3);

			failMesg  = "The sigmaSlope method was unsuccessful";
			//std::cout << "The Slope Uncertainty is: " << test.sigmaSlope() << std::endl;
			testFramework.assert(fabs(test.sigmaSlope() - 0.574456264653803) < eps, failMesg, __LINE__);
			return testFramework.countFails();
		}
Ejemplo n.º 26
0
	int dumpTest(void)
	{
		TestUtil testFramework("ObsID", "dump", __FILE__, __LINE__);
		std::string failMesg;
		gpstk::ObsID Compare(gpstk::ObsID::otDoppler, gpstk::ObsID::cbL2, gpstk::ObsID::tcY);
		
		std::string outputString, referenceString;
		std::stringstream outputStream;

		Compare.dump(outputStream);
		outputString = outputStream.str();

		referenceString = "L2 GPSY doppler";

		failMesg = "Did the dump method function correctly?";
		testFramework.assert(outputString == referenceString, failMesg, __LINE__);

		return testFramework.countFails();
	}
Ejemplo n.º 27
0
		int addTest()
		// Test to add data. Want to add single values to empty Stats class.
		// Then add another stat on top with weight. I will use the average to check
		// that data was added and that the data added was correct.
		{
			TestUtil testFramework("BivarStats","Add()",__FILE__,__LINE__);
			std::string failMesg;

			gpstk::BivarStats<double> test;
			test.add(1, 2);		
			test.add(2, 5);
			test.add(3, 1);
			test.add(4, 4);
			test.add(5, 3);

			failMesg  = "The Add method was unsuccessful";
			//std::cout << "The Average is: " << test.average() << std::endl;
			testFramework.assert(test.averageX() == 3, failMesg, __LINE__);
			return testFramework.countFails();
		}
Ejemplo n.º 28
0
//==========================================================================
//	initializationTest ensures the constructors set the values properly
//	get methods are tested implicitly
//==========================================================================
   int initializationTest(void)
   {
      gpstk::TestUtil testFramework("TimeSystem", "Constructor", __FILE__, __LINE__);
      std::string testMesg;

      gpstk::TimeSystem Empty;
      gpstk::TimeSystem ExplicitInt(2);
      gpstk::TimeSystem ExplicitString;
      ExplicitString.fromString("GLO");
      gpstk::TimeSystem Set;
      Set.setTimeSystem(gpstk::TimeSystem::Systems(5)); //QZSS

         //---------------------------------------------------------------------------
         //Checking the default constructor
         //---------------------------------------------------------------------------
      testMesg = "The default constructor stores the incorrect value";
      testFramework.assert(Empty.getTimeSystem() == 0, testMesg, __LINE__);
         //---------------------------------------------------------------------------
         //Checking the explicit constructor
         //---------------------------------------------------------------------------
      testMesg = "The explicit constructor stores the incorrect value";
      testFramework.assert(ExplicitInt.getTimeSystem() == 2, testMesg, __LINE__);
         //---------------------------------------------------------------------------
         //Checking the string constructor
         //---------------------------------------------------------------------------
      testMesg = "The fromString method stores the incorrect value";
      testFramework.assert(ExplicitString.getTimeSystem() == 3, testMesg, __LINE__);
         //---------------------------------------------------------------------------
         //Checking the set and get methods
         //---------------------------------------------------------------------------
      testMesg = "The setTimeSystem method stores the incorrect value";		
      testFramework.assert(Set.getTimeSystem() == 5, testMesg, __LINE__);

         //---------------------------------------------------------------------------
         //Checking the asString method
         //---------------------------------------------------------------------------
      testMesg = "The asString method reutrns the incorrect value";		
      testFramework.assert(ExplicitString.asString() == "GLO", testMesg, __LINE__);

      return testFramework.countFails();
   }
Ejemplo n.º 29
0
  // Testing Rinex3NavData with Rinex3EphemerisStore
  void dataTest( void )
  {

    TestUtil testFramework( "Rinex3EphemerisStore", "addToList", __FILE__, __LINE__ );
                        
    const short PRN6 = 6 ;
    gpstk::SatID sid6( PRN6, gpstk::SatID::systemGPS ); 

    try
    {
        gpstk::Rinex3EphemerisStore Store;
        Store.loadFile( "Logs/RinexNavExample.99n" );

        gpstk::CivilTime Time( 1999,9,2,17,51,44, TimeSystem::GPS );

        //Load data into GPSEphemerisStore object so can invoke findUserEphemeris on it

        std::list<gpstk::Rinex3NavData> R3NList;
        gpstk::GPSEphemerisStore GStore;
        std::list<gpstk::Rinex3NavData>::const_iterator it;
        Store.addToList( R3NList );
        for (it=R3NList.begin(); it != R3NList.end(); ++it)
          GStore.addEphemeris( gpstk::EngEphemeris(*it) );

        const gpstk::EngEphemeris& Eph6 = GStore.findUserEphemeris( sid6, Time );
        gpstk::RinexNavData Data( Eph6 );
        list<double> NavDataList = Data.toList();
        
        testFramework.assert( true, 'Load data into Rinex3EphemerisStore, convert to EngEphemeris, store in GPSEphemerisStore, extract with findUserEphemeris', __LINE__ );
    }
    catch( gpstk::Exception& e )
    {
        testFramework.assert( false, 'Threw an unexpected exception', __LINE__ );
    }

    return testFramework.countFails();

  }
Ejemplo n.º 30
0
//==========================================================================================================================
//	constructorTest ensures the constructors set the object properly
//==========================================================================================================================
		int constructorTest(void)
		{
			TestUtil testFramework( "PolyFit", "Constructor", __FILE__, __LINE__ );
			try
			{
				//---------------------------------------------------------------------
				//Test the default constructor
				//---------------------------------------------------------------------
				try
				{
					gpstk::PolyFit<double> PolyCheck;
					testFramework.assert(true, "Default constructor successfully built a PolyFit object", __LINE__);
				}
				catch(...){testFramework.assert(false, "Unexpected exception thrown during default construction of a PolyFit object", __LINE__); }
				gpstk::PolyFit<double> Poly;
				testFramework.assert((unsigned) 0 == Poly.N()     , "Default constructor created an object with data in it"    , __LINE__);
				testFramework.assert((unsigned) 0 == Poly.Degree(), "Default constructor allows for non-constant fits"         , __LINE__);
				testFramework.assert(Poly.isSingular()            , "The fit found after default construction was not singular", __LINE__);

				//---------------------------------------------------------------------
				//Test the explicit constructor
				//---------------------------------------------------------------------
				try
				{
					gpstk::PolyFit<double> PolyCheck(4);
					testFramework.assert(true, "Explicit constructor successfully built a PolyFit object", __LINE__);
				}
				catch(...){testFramework.assert(false, "Unexpected exception thrown during explicit construction of a PolyFit object", __LINE__); }
				gpstk::PolyFit<double> Poly4((unsigned) 4);
				testFramework.assert((unsigned) 0 == Poly4.N()     , "Explicit constructor created an object with data in it"            , __LINE__);
				testFramework.assert((unsigned) 4 == Poly4.Degree(), "Explicit constructor does not fit polynomials of the correct order", __LINE__);
				testFramework.assert(Poly4.isSingular()            , "The fit found after explicit construction was not singular"        , __LINE__);
			}
			catch (gpstk::Exception& e) {}

			return testFramework.countFails();
		}