54 gnsstk::TestUtil testFramework(
"stl_helpers",
"Max and Min", __FILE__, __LINE__);
57 std::list<int> ilist1;
58 std::list<int> ilist2;
59 std::list<float> flist1;
60 std::list<float> flist2;
62 for (
int i=0; i<5; i++) {ilist1.push_back(i+1);};
65 ilist2.push_back(-90);
67 ilist2.push_back(100);
70 for (
float i=0; i<5; i++) {flist1.push_back(i+1);};
73 flist2.push_back(-90);
75 flist2.push_back(100);
82 testMesg =
"gnsstk::max() did not return the maximum value of a integer";
85 testMesg =
"gnsstk::max() did not return the maximum value of a float";
92 testMesg =
"gnsstk::min() did not return the minimum value of a integer";
95 testMesg =
"gnsstk::min() did not return the minimum value of a float";
108 std::string testMesg;
111 std::list<int> ilist1;
112 std::list<float> flist1;
114 for (
int i=0; i<5; i++) {ilist1.push_back(i+1);};
115 for (
float i=0; i<5; i++) {flist1.push_back(i+1);};
117 gnsstk::stats<int> (ilist1);
118 gnsstk::stats<float> (flist1);
120 float expectedN = 5.0;
121 float expectedMean = 3.0;
122 float expectedSigma = 2.5;
123 expectedSigma = std::sqrt(2.5);
128 testMesg =
"The computed n value is incorrect for a integer";
129 testFramework.
assert(gnsstk::stats<int>(ilist1).n == 5, testMesg, __LINE__);
130 testMesg =
"The computed n value is incorrect for a float";
131 testFramework.
assert(fabs(gnsstk::stats<float>(flist1).n - expectedN) <
eps, testMesg, __LINE__);
136 testMesg =
"The computed mean value is incorrect for a integer";
137 testFramework.
assert(gnsstk::stats<int>(ilist1).mean == 3, testMesg, __LINE__);
138 testMesg =
"The computed mean value is incorrect for a float";
139 testFramework.
assert(fabs(gnsstk::stats<float>(flist1).mean - expectedMean) <
eps, testMesg, __LINE__);
144 testMesg =
"The computed sigma value is incorrect for a integer";
145 testFramework.
assert(gnsstk::stats<int>(ilist1).sigma == 1, testMesg, __LINE__);
146 testMesg =
"The computed sigma value is incorrect for a float";
147 testFramework.
assert(fabs(gnsstk::stats<float>(flist1).sigma - expectedSigma) <
eps, testMesg, __LINE__);
156 gnsstk::TestUtil testFramework(
"stl_helpers",
"VectorIndex", __FILE__, __LINE__);
157 std::string testMesg;
159 std::vector<int> iOneTime(5);
160 for (
int i=0; i<5; i++) {iOneTime[i] = i;};
161 std::vector<int> iTwoTimes(5);
167 std::vector<int> iNone(5);
168 for (
int i=10; i<15; i++) {iNone[i-10] = i;};
170 std::vector<float> fOneTime(5);
171 for (
float i=0; i<5; i++) {fOneTime[i] = i;};
172 std::vector<float> fTwoTimes(5);
178 std::vector<float> fNone(5);
179 for (
float i=10; i<15; i++) {iNone[i-10] = i;};
182 int expectedIndexOneTime = 3;
183 int expectedIndexTwoTimes = 2;
184 int expectedIndexNone = -1;
186 testMesg =
"VectorIndex() did not find the first instance of a given integer element";
187 testFramework.
assert(gnsstk::vectorindex<int>(iOneTime, 3) == expectedIndexOneTime, testMesg, __LINE__);
188 testFramework.
assert(gnsstk::vectorindex<int>(iTwoTimes, 3) == expectedIndexTwoTimes, testMesg, __LINE__);
189 testFramework.
assert(gnsstk::vectorindex<int>(iNone, 3) == expectedIndexNone, testMesg, __LINE__);
191 testMesg =
"VectorIndex() did not find the first instance of a given float element";
192 testFramework.
assert(gnsstk::vectorindex<float>(fOneTime, 3) == expectedIndexOneTime, testMesg, __LINE__);
193 testFramework.
assert(gnsstk::vectorindex<float>(fTwoTimes, 3) == expectedIndexTwoTimes, testMesg, __LINE__);
194 testFramework.
assert(gnsstk::vectorindex<float>(fNone, 3) == expectedIndexNone, testMesg, __LINE__);
208 int check, errorCounter = 0;
211 errorCounter += check;
214 errorCounter += check;
217 errorCounter += check;
219 std::cout <<
"Total Failures for " << __FILE__ <<
": " << errorCounter << std::endl;