static void GenericIteratorTest(ValueStrategy strategy, int32 maxNumber) { typedef typename ValueStrategy::Value Value; TestVector<Value> v; GenericFill(v, strategy, maxNumber); const TestVector<Value> &cv = v; typename TestVector<Value>::Iterator it = v.Begin(); typename TestVector<Value>::ConstIterator cit = cv.Begin(); for (; it != v.End(); ++it, ++cit) { CHK(&*it == &*cit); CHK(&*it == it.operator->()); CHK(&*cit == cit.operator->()); CHK(it); CHK(cit); } CHK(cit == cv.End()); while (it != v.Begin()) { --it; --cit; CHK(&*it == &*cit); CHK(&*it == it.operator->()); CHK(&*cit == cit.operator->()); CHK(it); CHK(cit); } CHK(cit == cv.Begin()); CHK(!v.Null()); CHK(!cv.Null()); }
static void GenericFindTest(ValueStrategy strategy, int32 maxNumber) { typedef typename ValueStrategy::Value Value; TestVector<Value> v; GenericFill(v, strategy, maxNumber); // find the values in the vector const TestVector<Value> &cv = v; for (int32 i = 0; i < maxNumber; i++) { typename TestVector<Value>::ConstIterator cit = cv.Begin(); int32 index = 0; for (typename TestVector<Value>::Iterator it = v.Begin(); it != v.End(); ) { CHK(&v[index] == &*it); CHK(&cv[index] == &*cit); CHK(*it == *cit); it = v.Find(v[i], ++it); cit = cv.Find(cv[i], ++cit); index = v.IndexOf(v[i], index + 1); } } // try to find some random values for (int32 i = 0; i < maxNumber; i++) { Value value = strategy.Generate(); typename TestVector<Value>::Iterator it = v.Find(value); typename TestVector<Value>::ConstIterator cit = cv.Find(value); if (it != v.End()) CHK(&*it == &*cit); } }