55 TestUtil testFramework(
"Triple",
"Set", __FILE__, __LINE__ );
58 Triple test, test2(1,2,3), test3(test2);
59 test = valarray<double>(3);
63 failMesg =
"Was tje Triple created correctly?";
64 testFramework.
assert((test.
size() == 3) && (test2.size() == 3) && (test3.
size() == 3), failMesg, __LINE__);
71 TestUtil testFramework(
"Triple",
"Dot", __FILE__, __LINE__ );
74 Triple test(1,2,3),test2(2,2,2);
77 result = test.dot(test2);
81 failMesg =
"Did the dot method function properly?";
82 testFramework.
assert(result == 12, failMesg, __LINE__);
89 TestUtil testFramework(
"Triple",
"Cross", __FILE__, __LINE__ );
92 Triple test(1,2,3), test2(2,2,2), test3;
94 test3 = test.
cross(test2);
98 failMesg =
"Did the method function properly?";
99 testFramework.
assert((test3[0] == -2) && (test3[1] == 4) && (test3[2] == -2), failMesg, __LINE__);
106 TestUtil testFramework(
"Triple",
"Mag", __FILE__, __LINE__ );
107 std::string failMesg;
111 failMesg =
"Did the calculation return the correct values?";
112 testFramework.
assert(test.
mag() == 5, failMesg, __LINE__);
114 test[0] = 0; test[1] = 0; test[2] = -2;
116 failMesg =
"Did the calculation return the correct values?";
117 testFramework.
assert(test.
mag() == 2, failMesg, __LINE__);
124 TestUtil testFramework(
"Triple",
"unitVector", __FILE__, __LINE__ );
125 std::string failMesg;
130 failMesg =
"Did the calculation return the correct values?";
131 testFramework.
assert( (fabs(test2[0] - 3.0/5.0)*5.0/3.0 < eps) && (fabs(test2[1] - 4.0/5.0)*5.0/4.0 < eps) && (fabs(test2[2]) < eps) , failMesg, __LINE__);
133 test[0] = 0; test[1] = 0; test[2] = -2;
136 failMesg =
"Did the calculation return the correct values?";
137 testFramework.
assert((test2[0] == 0) && (test2[1] == 0) && (test2[2] == -1.0), failMesg, __LINE__);
144 TestUtil testFramework(
"Triple",
"cosVector", __FILE__, __LINE__ );
145 std::string failMesg;
147 Triple test(1,0,1),test2(-1,0,-1);
149 failMesg =
"Is the computed cosine value correct?";
150 testFramework.
assert(fabs(test.cosVector(test2) + 1) < eps, failMesg, __LINE__);
152 test2[0] = 0; test2[1] = 1; test2[2] = 0;
154 failMesg =
"Is the computed cosine value correct?";
155 testFramework.
assert(fabs(test.cosVector(test2)) < eps, failMesg, __LINE__);
157 test[0] = 1; test[1] = 0; test[2] = 0;
158 test2[0] = 1; test2[1] = 1; test2[2] = 0;
160 failMesg =
"Is the computed cosine value correct?";
161 testFramework.
assert(fabs(test.cosVector(test2) - sqrt(2.0)/2.0) < eps, failMesg, __LINE__);
168 TestUtil testFramework(
"Triple",
"slantRange", __FILE__, __LINE__ );
169 std::string failMesg;
171 Triple test(4,6,3),test2(1,2,3);
173 failMesg =
"Was the slant range calculation computed correctly?";
174 testFramework.
assert(fabs(test.slantRange(test2)- 5) < eps, failMesg, __LINE__);
176 test[0] = 11; test[1] = -12; test[2] = 10;
177 test2[0] = 1; test2[1] = 2; test2[2] = 3;
179 failMesg =
"Was the slant range calculation computed correctly?";
180 testFramework.
assert(fabs(test.slantRange(test2) - sqrt(345.0)) < eps, failMesg, __LINE__);
187 TestUtil testFramework(
"Triple",
"elvAngle", __FILE__, __LINE__ );
188 std::string failMesg;
190 Triple test(1,0,0),test2(0,-1,0);
193 failMesg =
"Was the elevation angle calculation computed correctly?";
194 testFramework.
assert(fabs(test.elvAngle(test2) + 45) < eps, failMesg, __LINE__);
196 test[0] = 11; test[1] = -12; test[2] = 10;
197 test2[0] = 1; test2[1] = 2; test2[2] = 3;
198 result = acos(-348.0/(sqrt(365.0)*sqrt(345.0)))*180.0/(4.0*atan(1.0));
199 result = 90 - result;
201 failMesg =
"Was the elevation angle calculation computed correctly?";
202 testFramework.
assert(fabs(test.elvAngle(test2) - result) < eps, failMesg, __LINE__);
204 test[0] = 1; test[1] = 1; test[2] = 1;
205 test2[0] = 1; test2[1] = 0; test2[2] = 0;
207 failMesg =
"Was the elevation angle calculation computed correctly?";
208 testFramework.
assert(fabs(test.elvAngle(test2) - (90 - acos(-2.0/sqrt(6.0))*180.0/(4.0*atan(1.0)))) < eps, failMesg, __LINE__);
216 TestUtil testFramework(
"Triple",
"azAngle", __FILE__, __LINE__ );
217 std::string failMesg;
219 Triple test(1,1,1),test2(-1,1,1);
221 failMesg =
"Was the azimutal angle calculation computed correctly?";
222 testFramework.
assert(fabs(test.azAngle(test2) - 60) < eps, failMesg, __LINE__);
224 test[0] = 11; test[1] = -12; test[2] = 10;
225 test2[0] = 1; test2[1] = 2; test2[2] = 3;
227 failMesg =
"Was the azimutal angle calculation computed correctly?";
228 testFramework.
assert(fabs(test.azAngle(test2) - 35.0779447169289) < eps, failMesg, __LINE__);
230 test[0] = 1; test[1] = 0; test[2] = 0;
231 test2[0] = 0; test2[1] = 1; test2[2] = 0;
233 failMesg =
"Was the azimutal angle calculation computed correctly?";
234 testFramework.
assert(fabs(test.azAngle(test2) - 90)/90 < eps, failMesg, __LINE__);
236 test[0] = 1; test[1] = -1; test[2] = 1;
237 test2[0] = 1; test2[1] = 1; test2[2] = 1;
239 failMesg =
"Was the azimutal angle calculation computed correctly?";
240 testFramework.
assert(fabs(test.azAngle(test2) - 60)/60 < eps, failMesg, __LINE__);
246 test2[0] = 0; test2[1] = 0; test2[2] = 0;
247 failMesg =
"[testing] Triple.azAngle() at origin, [expected] exception gnsstk::Exception, [actual] threw no exception";
248 try {test.
azAngle(test2); testFramework.
assert(
false, failMesg, __LINE__);}
252 failMesg =
"[testing] Triple.azAngle() at origin, [expected] exception gnsstk::Exception, [actual] threw different exception";
253 testFramework.
assert(
false, failMesg, __LINE__);
259 test[0] = 0; test[1] = 0; test[2] = -1;
260 test2[0] = 1; test2[1] = 1; test2[2] = 1;
261 failMesg =
"[testing] Triple.azAngle() at origin and due south, [expected] exception gnsstk::Exception, [actual] threw no exception";
262 try {test.
azAngle(test2); testFramework.
assert(
false, failMesg, __LINE__);}
266 failMesg =
"[testing] Triple.azAngle() at origin and due south, [expected] exception gnsstk::Exception, [actual] threw no exception";
267 testFramework.
assert(
false, failMesg, __LINE__);
278 int check, errorCounter = 0;
282 errorCounter += check;
285 errorCounter += check;
288 errorCounter += check;
291 errorCounter += check;
294 errorCounter += check;
297 errorCounter += check;
300 errorCounter += check;
303 errorCounter += check;
306 errorCounter += check;
308 std::cout <<
"Total Failures for " << __FILE__ <<
": " << errorCounter << std::endl;