24 #define fei_file "test_misc.cpp"
38 FEI_COUT <<
"testing fei::FieldMask...";
42 unsigned numFields = 5;
43 std::vector<int> fieldIDs(numFields);
44 std::vector<int> fieldSizes(numFields);
45 int checkNumIndices = 0;
46 for(
unsigned i=0; i<numFields; ++i) {
54 for(
int i=fieldIDs.size()-1; i>= 0; --i) {
55 fieldMask.
addField(fieldIDs[i], fieldSizes[i]);
58 std::vector<int>& maskFields = fieldMask.
getFieldIDs();
61 if (maskFields != fieldIDs) {
62 throw std::runtime_error(
"FieldMask test failed.");
65 if (maskFieldSizes != fieldSizes) {
66 throw std::runtime_error(
"FieldMask size test failed.");
70 for(
unsigned j=0; j<fieldIDs.size(); ++j) {
73 if (offset != checkOffset) {
74 throw std::runtime_error(
"FieldMask offset test failed.");
80 if (numIndices != checkNumIndices) {
81 throw std::runtime_error(
"FieldMask numIndices test failed.");
84 bool exc_caught =
false;
93 throw std::runtime_error(
"FieldMask failed to throw on negative fieldID.");
99 throw std::runtime_error(
"FieldMask getNumFields test failed.");
115 fm123.
addField(fieldid2, fieldsize);
116 fm123.
addField(fieldid3, fieldsize);
119 throw std::runtime_error(
"FieldMask getMaskID test failed.");
123 throw std::runtime_error(
"FieldMask getMaskID2 test failed.");
128 throw std::runtime_error(
"FieldMask getMaskID3 test failed.");
132 throw std::runtime_error(
"FieldMask getMaskID4 test failed.");
137 throw std::runtime_error(
"FieldMask getMaskID5 test failed.");
141 throw std::runtime_error(
"FieldMask getMaskID6 test failed.");
149 FEI_COUT <<
"testing snl_fei::RecordCollection...";
158 std::vector<fei::FieldMask*> fieldMasks;
162 int* records =
new int[1];
165 fieldMasks, records);
168 fieldMasks, records);
171 fieldMasks, records);
174 fieldMasks, records);
177 fieldMasks, records);
180 fieldMasks, records);
182 if (fieldMasks.size() != 5) {
183 throw std::runtime_error(
"RecordCollection fieldMasks.length test failed.");
186 std::vector<fei::Record<int> >& rvec = recColl.
getRecords();
188 std::vector<fei::Record<int> >::iterator
189 r_iter = rvec.begin(),
193 for(; r_iter != r_end; ++r_iter) {
194 numIndices += (*r_iter).getFieldMask()->getNumIndices();
197 if (numIndices != 6) {
198 throw std::runtime_error(
"RecordCollection numIndices test failed.");
202 for(
unsigned i=0; i<fieldMasks.size(); ++i)
delete fieldMasks[i];
227 FEI_COUT <<
"testing fei_test_utils::within_percentage_margin...";
228 double value1 = 65000.0;
229 double value2 = 6500.0;
231 if (result ==
true) {
238 if (result !=
true) {
245 if (result ==
true) {
252 if (result !=
true) {
262 FEI_COUT <<
"testing fei::lowerBound...";
263 std::vector<int> list(5);
272 int lowerbound = fei::lowerBound<int>(item, &list[0], list.size());
274 if (lowerbound != 0) {
275 throw std::runtime_error(
"failed test 1");
279 lowerbound = fei::lowerBound<int>(item, &list[0], list.size());
281 if (lowerbound != 0) {
282 throw std::runtime_error(
"failed test 2");
286 lowerbound = fei::lowerBound<int>(item, &list[0], list.size());
288 if (lowerbound != 1) {
289 throw std::runtime_error(
"failed test 3");
293 lowerbound = fei::lowerBound<int>(item, &list[0], list.size());
295 if (lowerbound != 3) {
296 throw std::runtime_error(
"failed test 4");
300 lowerbound = fei::lowerBound<int>(item, &list[0], list.size());
302 if (lowerbound != 4) {
303 throw std::runtime_error(
"failed test 5");
307 lowerbound = fei::lowerBound<int>(item, &list[0], list.size());
309 if (lowerbound != 4) {
310 throw std::runtime_error(
"failed test6");
314 lowerbound = fei::lowerBound<int>(item, &list[0], list.size());
316 if (lowerbound != 5) {
317 throw std::runtime_error(
"failed test 7");
320 lowerbound = fei::lowerBound<int>(item, (
int*)0, (
int)0);
322 if (lowerbound != 0) {
323 throw std::runtime_error(
"failed test 8");
326 std::vector<int> list2;
330 lowerbound = fei::lowerBound<int>(item, &list2[0], list2.size());
332 if (lowerbound != 0) {
333 throw std::runtime_error(
"failed test 9");
337 lowerbound = fei::lowerBound<int>(item, &list2[0], list2.size());
339 if (lowerbound != 1) {
340 throw std::runtime_error(
"failed test 10");
350 FEI_COUT <<
"testing snl_fei::MapContig<fei::ctg_set<int>*>...";
357 for(
int i=1; i<6; ++i) {
362 for(
int j=0; j<3; ++j) {
366 std::pair<int,fei::ctg_set<int>*> newpair(i,newset);
373 throw std::runtime_error(
"failed test 1.");
377 mc_iter = mc.
begin(),
381 c_iter = m_copy.
begin(),
382 c_end = m_copy.
end();
384 for(; mc_iter != mc_end; ++mc_iter) {
385 std::pair<int,fei::ctg_set<int>*> mc_pair = *mc_iter;
386 std::pair<int,fei::ctg_set<int>*> c_pair = *c_iter;
388 if (mc_pair.first != c_pair.first) {
389 throw std::runtime_error(
"failed test 2.");
392 if (*(mc_pair.second) != *(c_pair.second)) {
393 throw std::runtime_error(
"failed test 3.");
398 mc_iter = mc.
begin();
399 for(; mc_iter != mc_end; ++mc_iter) {
400 pool_alloc.
destroy((*mc_iter).second);
void construct(U *p, const U &val)
void test_misc_RecordCollection()
std::vector< fei::Record< int > > & getRecords()
void test_misc_FieldMask()
int getNumIndices() const
pointer allocate(size_type n, const void *hint=NULL)
size_t getNumFields() const
std::vector< int > & getFieldSizes()
void insert2(const T &item)
std::pair< iterator, bool > insert(value_type val)
std::vector< int > & getFieldIDs()
void addField(int fieldID, int fieldSize)
bool within_percentage_margin(double value1, double value2, unsigned margin)
int getFieldEqnOffset(int fieldID, int &offset) const
void initRecords(int numIDs, const int *IDs, std::vector< fei::FieldMask * > &fieldMasks, int *recordLocalIDs=NULL)