00001 #pragma ident "$Id: testExpression.cpp 1895 2009-05-12 19:34:29Z afarris $"
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include <iostream>
00026 #include <iomanip>
00027
00028 #include "RinexObsStream.hpp"
00029 #include "Expression.hpp"
00030
00031 using namespace std;
00032 using namespace gpstk;
00033
00034 int main(int argc, char* argv[])
00035 {
00036 short test=1;
00037
00038 cout << endl << "Unit Test #" << setw(2) << test++ << " -----------------------------------" << endl;
00039 {
00040 string istr(" 1 + (6 - 2 ) * 3.2");
00041 Expression xpr(istr);
00042 cout << "Input string: \"" << istr << "\"" << endl;
00043 xpr.print(cout);
00044 cout << "=" << xpr.evaluate() << endl;
00045 }
00046
00047 cout << endl << "Unit Test #" << setw(2) << test++ << " -----------------------------------" << endl;
00048 try {
00049 string istr(" 1 + (6 - gamma ) * 3.2");
00050 Expression xpr(istr);
00051 cout << "Input string: \"" << istr << "\"" << endl;
00052 xpr.print(cout);
00053 cout << "=" << xpr.evaluate() << endl;
00054 }
00055 catch (gpstk::Expression::ExpressionException ee)
00056 {
00057 cout << endl << "The expected exception was generated: " << endl;
00058 cout << ee << endl;
00059 }
00060
00061 cout << endl << "Unit Test #" << setw(2) << test++ << " -----------------------------------" << endl;
00062 {
00063 string istr(" 1 + 2*(3 + 1)");
00064 Expression xpr(istr);
00065 cout << "Input string: \"" << istr << "\"" << endl;
00066 xpr.print(cout);
00067 cout << "=" << xpr.evaluate() << endl;
00068 }
00069
00070 cout << endl << "Unit Test #" << setw(2) << test++ << " -----------------------------------" << endl;
00071 {
00072 try {
00073 string istr(" 1 + 2*( beta + 1)");
00074 Expression xpr(istr);
00075 cout << "Input string: \"" << istr << "\"" << endl;
00076 xpr.print(cout);
00077 xpr.set("beta",1);
00078 cout << "=" << xpr.evaluate() << endl;
00079 }
00080 catch (...)
00081 {
00082 cout << "An unexpected exception was generated: ";
00083 }
00084 }
00085
00086 cout << endl << "Unit Test #" << setw(2) << test++ << " -----------------------------------" << endl;
00087 {
00088 string istr(" 1 + 2*cos(3.141592647)");
00089 Expression xpr(istr);
00090 cout << "Input string: \"" << istr << "\"" << endl;
00091 xpr.print(cout);
00092 cout << "=" << xpr.evaluate() << endl;
00093 }
00094
00095 cout << endl << "Unit Test #" << setw(2) << test++ << " -----------------------------------" << endl;
00096 {
00097 string istr(" 1E+1 + 4* 2E-2");
00098 Expression xpr(istr);
00099 cout << "Input string: \"" << istr << "\"" << endl;
00100 xpr.print(cout);
00101 cout << "=" << xpr.evaluate() << endl;
00102 }
00103
00104 cout << endl << "Unit Test #" << setw(2) << test++ << " -----------------------------------" << endl;
00105 {
00106 string istr("C/L1");
00107 Expression xpr(istr);
00108 xpr.setGPSConstants();
00109 cout << "Input string: \"" << istr << "\"" << endl;
00110 xpr.print(cout);
00111 cout << "=" << xpr.evaluate() << endl;
00112 }
00113
00114 cout << endl << "Unit Test #" << setw(2) << test++ << " -----------------------------------" << endl;
00115 {
00116 string istr("1/(1-gamma)*(P1 - P2)");
00117 cout << "Input string: \"" << istr << "\"" << endl;
00118 Expression xpr(istr);
00119 xpr.print(cout);
00120 cout << endl;
00121 xpr.setGPSConstants();
00122
00123 RinexObsStream ros("../examples/bahr1620.04o");
00124 RinexObsData rod;
00125 for (int i=0;i<3;i++)
00126
00127 {
00128 ros >> rod;
00129
00130 RinexObsData::RinexPrnMap::const_iterator it;
00131 for (it = rod.obs.begin(); it!= rod.obs.end(); it++)
00132 {
00133 xpr.setRinexObs(it->second);
00134 cout << rod.time << " " << it->first.prn << " ";
00135 cout << xpr.evaluate() << endl;
00136 }
00137 }
00138 }
00139
00140 exit(0);
00141 }