Ejemplo n.º 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());
}
Ejemplo n.º 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 );
    }
}
Ejemplo n.º 3
0
int main(void)
{
   std::cout << "Flood Neural Network. Test Vector Application." << std::endl;

   TestVector tv;
                  
   tv.print_results();

   return(0);
}  
Ejemplo n.º 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();
}
Ejemplo n.º 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));
	}
}
Ejemplo n.º 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));
	}
}
Ejemplo n.º 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();
}
Ejemplo n.º 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));
	}
}
Ejemplo n.º 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);
	}
}
Ejemplo n.º 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);
	}
}
Ejemplo n.º 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();
}
Ejemplo n.º 12
0
void foo(TestVector a)
{
	barfo = a.size();	// Do something so foo wont be optimized out.
}
Ejemplo n.º 13
0
 void operator()( TestVector& v ) const
 {
     v.reserve( fAmount );
 }
Ejemplo n.º 14
0
void prepare_insert_n( TestVector& c, EH_STD::size_t insCnt )
{
    if ( random_number(2) )
        c.reserve( c.size() + insCnt );
}
Ejemplo n.º 15
0
int main()
{
        TestVector tvector;
        tvector.run();
        tvector.report();
}