Exemple #1
0
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());
}
Exemple #2
0
inline void prepare_insert_range( TestVector& vec, EH_STD::size_t, TestClass* first, TestClass* last )
{
    if ( random_number(2) )
    {
        EH_STD::ptrdiff_t d = 0;
        EH_DISTANCE( first, last, d );
        vec.reserve( vec.size() + d );
    }
}
Exemple #3
0
int main(void)
{
   std::cout << "Flood Neural Network. Test Vector Application." << std::endl;

   TestVector tv;
                  
   tv.print_results();

   return(0);
}  
Exemple #4
0
static
void
GenericMakeEmptyTest(ValueStrategy strategy, int32 maxNumber)
{
	typedef typename ValueStrategy::Value Value;
	TestVector<Value> v;
	v.MakeEmpty();
	GenericFill(v, strategy, maxNumber);
	v.MakeEmpty();
	v.MakeEmpty();
}
Exemple #5
0
static
void
GenericInsertTest2(ValueStrategy strategy, int32 maxNumber)
{
	typedef typename ValueStrategy::Value Value;
	TestVector<Value> v;
	for (int32 i = 0; i < maxNumber; i++) {
		int32 index = rand() % (i + 1);
		v.Insert(strategy.Generate(), v.IteratorForIndex(index));
	}
}
Exemple #6
0
static
void
GenericEraseTest2(ValueStrategy strategy, int32 maxNumber)
{
	typedef typename ValueStrategy::Value Value;
	TestVector<Value> v;
	GenericFill(v, strategy, maxNumber);
	for (int32 i = maxNumber - 1; i >= 0; i--) {
		int32 index = rand() % (i + 1);
		v.Erase(v.IteratorForIndex(index));
	}
}
Exemple #7
0
static
void
GenericFill(TestVector<Value> &v, ValueStrategy strategy, int32 maxNumber)
{
	v.SetChecking(false);
	for (int32 i = 0; i < maxNumber; i++) {
		int32 index = rand() % (i + 1);
		v.Insert(strategy.Generate(), index);
	}
	v.SetChecking(true);
	v.Check();
}
Exemple #8
0
static
void
GenericIndexAccessTest(ValueStrategy strategy, int32 maxNumber)
{
	typedef typename ValueStrategy::Value Value;
	TestVector<Value> v;
	GenericFill(v, strategy, maxNumber);
	const TestVector<Value> &cv = v;
	for (int32 i = 0; i < maxNumber; i++) {
		CHK(v[i] == cv[i]);
		CHK(v.ElementAt(i) == cv.ElementAt(i));
	}
}
Exemple #9
0
static
void
GenericRemoveTest(ValueStrategy strategy, int32 maxNumber)
{
	typedef typename ValueStrategy::Value Value;
	TestVector<Value> v;
	GenericFill(v, strategy, maxNumber);
	while (v.Count() > 0) {
		int32 index = rand() % (v.Count());
		Value value = v[index];
		v.Remove(value);
		v.Remove(value);
	}
}
Exemple #10
0
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);
	}
}
Exemple #11
0
static
void
GenericPushPopBackTest(ValueStrategy strategy, int32 maxNumber)
{
	typedef typename ValueStrategy::Value Value;
	TestVector<Value> v;
	for (int32 i = 0; i < maxNumber; i++)
		v.PushBack(strategy.Generate());
	for (int32 i = 0; i < maxNumber / 2; i++)
		v.PopBack();
	for (int32 i = 0; i < maxNumber; i++)
		v.PushBack(strategy.Generate());
	int32 count = v.Count();
	for (int32 i = 0; i < count; i++)
		v.PopBack();
}
Exemple #12
0
void foo(TestVector a)
{
	barfo = a.size();	// Do something so foo wont be optimized out.
}
Exemple #13
0
 void operator()( TestVector& v ) const
 {
     v.reserve( fAmount );
 }
Exemple #14
0
void prepare_insert_n( TestVector& c, EH_STD::size_t insCnt )
{
    if ( random_number(2) )
        c.reserve( c.size() + insCnt );
}
Exemple #15
0
int main()
{
        TestVector tvector;
        tvector.run();
        tvector.report();
}