Exemple #1
0
void testObservations() {
  printf("== TEST OBSERVATIONS ==\n");
  printf("- Testing construction\n");
  RLObservation obs(3);
  RLObservation obs2(3);
  for (int i=0; i<3; i++) {
    obs[i] = observation[i];
    obs2[i] = observation2[i];
  }
  printf("-> PASSED\n");

  printf("- Testing [] operator\n");
  for (int i=0; i<3; i++) {
    printf("%f %f\n", obs.observations[i], observation[i]);
    assert( obs[i] == observation[i] );
  }
  printf("-> PASSED\n");

  printf("- Testing copyFrom\n");
  obs.copyFrom(obs2);
  for (int i=0; i<3; i++)
    assert( obs[i] == observation2[i] );
  printf("-> PASSED\n");

}
Exemple #2
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();
	}
Exemple #3
0
	int WxObsDataTest(void)
	{
		TestUtil testFramework("WxObsMap", "Default Constructor", __FILE__, __LINE__);
		std::string failMesg;

		gpstk::WxObsData Compare;

		failMesg = "Was the default value stored?";
		testFramework.assert(Compare.firstTime == gpstk::CommonTime::END_OF_TIME, failMesg, __LINE__);

		failMesg = "Was the default value stored?";
		testFramework.assert(Compare.lastTime == gpstk::CommonTime::BEGINNING_OF_TIME, failMesg, __LINE__);

		testFramework.changeSourceMethod("insertObservation");

		gpstk::CommonTime cTime;
		cTime.set((double)1000);

		for (int i = 0; i < 10; i++)
		{
			cTime.set((double)1000+i);
			Compare.insertObservation(gpstk::WxObservation(cTime,
					100+i, (50+i)*0.001, (80+i)*0.001));
		}

		//scale time counter back to access a stored observation
		cTime.set((double)1008);

		failMesg = "Was the WxObservation object stored in the map?";
		testFramework.assert(Compare.obs.count(cTime), failMesg, __LINE__);


		testFramework.changeSourceMethod("getMostRecent");

		gpstk::WxObservation obs1 = Compare.getMostRecent(cTime);	
		gpstk::WxObservation obs2(cTime, 108, 0.058f, 0.088f);

		//std::cout<<obs2<<std::endl<<obs1<<std::endl;
		
		//std::cout<<Compare.obs[cTime]<<std::endl;


		failMesg = "Did the getMostRecent method function correctly?";

		//should be able to do obs1 == obs2, but b/c theres no == operator...
		testFramework.assert(obs2.t == obs1.t && 
							obs2.temperature == obs1.temperature &&
							obs2.pressure == obs1.pressure &&
							obs2.humidity == obs1.humidity, failMesg, __LINE__);

		//verifying objects exist before deleting them
		cTime.set((double) 1001);
		failMesg = "Is the WxObservation object stored?	";
		testFramework.assert(Compare.obs.count(cTime), failMesg, __LINE__);
		cTime.set((double) 1002);
		failMesg = "Is the WxObservation object stored?		";
		testFramework.assert(Compare.obs.count(cTime), failMesg, __LINE__);

		cTime.set((double) 1003);
		//should erase 1001 and 1002 entries
		Compare.flush(cTime);

		cTime.set((double) 1001);
		failMesg = "Was the WxObservation object erased?		";
		testFramework.assert(!Compare.obs.count(cTime), failMesg, __LINE__);
		cTime.set((double) 1002);
		failMesg = "Was the WxObservation object erased?		";
		testFramework.assert(!Compare.obs.count(cTime), failMesg, __LINE__);

		testFramework.changeSourceMethod("getWxObservation");

		failMesg = "[testing] WxObs.getWxObservation with a non-existent object, [expected] exception gpstk::Exception, [actual] threw no exception";
		try{ Compare.getWxObservation(cTime, 0, false); testFramework.assert(false, failMesg, __LINE__); }
		catch (gpstk::Exception e) { testFramework.assert(true, failMesg, __LINE__); }

		//return right object for explicit case
		cTime.set((double)1003);
		gpstk::WxObservation obs3 = Compare.getWxObservation(cTime, 0, false);
		gpstk::WxObservation obs4(cTime, 103, 0.053f, 0.083f);

		failMesg = "Did the getWxObservation return the correct object when called explicitly?	";
		testFramework.assert(obs3.t == obs3.t && 
						obs3.temperature == obs4.temperature &&
						obs3.pressure == obs4.pressure &&
						obs3.humidity == obs4.humidity, failMesg, __LINE__);

		//return right object within range when theres only one
		cTime.set((double)1009);
		gpstk::WxObservation obs6(cTime, 109, 0.059f, 0.089f);
		cTime.set((double)1010);		
		gpstk::WxObservation obs5 = Compare.getWxObservation(cTime, 86401, false);

		failMesg = "Did the getWxObservation return the correct object when called in a range containing 1 object?";
		testFramework.assert(obs5.t == obs6.t && 
						obs5.temperature == obs6.temperature &&
						obs5.pressure == obs6.pressure &&
						obs5.humidity == obs6.humidity, failMesg, __LINE__);

		//return right object within range when theres multiple
		cTime.set((double)1006);
		gpstk::WxObservation obs8(cTime, 106, 0.056f, 0.086f);	
		gpstk::WxObservation obs7 = Compare.getWxObservation(cTime, 86401, false);

		failMesg = "Did the getWxObservation return the correct object when called in a range containing 2 objects?";
		testFramework.assert(obs7.t == obs8.t && 
						obs7.temperature == obs8.temperature &&
						obs7.pressure == obs8.pressure &&
						obs7.humidity == obs8.humidity, failMesg, __LINE__);

		//Linear Interpolation
		cTime.set((long)1007, (double)43200);
		//should have two values in range, where counter is 7 and 8
		gpstk::WxObservation obs9 = Compare.getWxObservation(cTime, 43200, true);
		//create object with what the interpolated values should be at the given time
		gpstk::WxObservation obs10(cTime, 107.5f, 0.0575f, 0.0875f);

		failMesg = "Did the getWxObservation perform linear interpolation succesfully?";
		testFramework.assert(abs(obs9.t - obs10.t) < singlePrecisionError && 
						abs(obs9.temperature - obs10.temperature) < singlePrecisionError&&
						abs(obs9.pressure - obs10.pressure) < singlePrecisionError &&
						abs(obs9.humidity - obs10.humidity) < singlePrecisionError, failMesg, __LINE__);
		
		return testFramework.countFails();
	}