예제 #1
0
//
//#############################################################################
//#############################################################################
//
bool
	Degree::TestClass()
{
	SPEW((GROUP_STUFF_TEST, "Starting Degree test..."));

	const Degree a(Degrees_Per_Radian);
	Degree
		b,c;

	Radian
		r(1.0f),s;

	s = a;
	Test_Assumption(r == s);
	b = r;
	s = b;
#if 0
	Test_Assumption(r == s);
#endif
	c = Degrees_Per_Radian;
	s = c;
#if 0
	Test_Assumption(r == s);
#endif
	b = c;
	s = b;
#if 0
	Test_Assumption(r == s);
#endif

	return true;
}
예제 #2
0
bool
	Random::TestClass()
{
	SPEW((GROUP_STUFF_TEST, "Starting Random::Instance test..."));

#define RANDOM_TEST_COUNT 10000

	int i;
	for (i=0; i<RANDOM_TEST_COUNT; ++i)
	{
		Scalar r = Random::Instance->GetFraction();
		Test_Assumption(r >= 0.0f && r < 1.0f);
	}

	int array[10];
	for (i = 0; i<ELEMENTS(array); ++i)
	{
		array[i] = 0;
	}

	for (i = 0; i<RANDOM_TEST_COUNT; ++i)
	{
		int r = Random::Instance->GetLessThan(ELEMENTS(array));
		Test_Assumption(r >= 0 && r < ELEMENTS(array));
		++array[r];
	}

	return true;
}
예제 #3
0
//
//#############################################################################
//#############################################################################
//
bool
EulerAngles::TestClass()
{
    SPEW((GROUP_STUFF_TEST, "Starting EulerAngle test..."));

    const EulerAngles
    a(Identity);
    EulerAngles
    b;
    const EulerAngles
    c(Pi_Over_4,Pi_Over_6,Pi_Over_3);

    Test_Assumption(!a.pitch && !a.yaw && !a.roll);
    Test_Assumption(c.pitch == Pi_Over_4 && c.yaw == Pi_Over_6 && c.roll == Pi_Over_3);

    Test_Assumption(!a);
    b = c;
    Test_Assumption(b == c);
    Test_Assumption(b != a);

    Test_Assumption(b[Y_Axis] == b.yaw);
    Test_Assumption(c[Z_Axis] == c.roll);

    b.Lerp(a,c,0.5f);
    Test_Assumption(b == EulerAngles(Stuff::Lerp(a.pitch,c.pitch,0.5f),Stuff::Lerp(a.yaw,c.yaw,0.5f),Stuff::Lerp(a.roll,c.roll,0.5f)));

    LinearMatrix4D m;
    m.BuildRotation(c);
    b = m;
    Test_Assumption(b == c);

    return true;
}
예제 #4
0
//
//#############################################################################
//#############################################################################
//
bool
	SinCosPair::TestClass()
{
	SPEW((GROUP_STUFF_TEST, "Starting SinCos test..."));
	Radian
		s,r(Pi_Over_2);

	SinCosPair a;
	a = r;

	Test_Assumption(Close_Enough(a.sine,1.0f));
	Test_Assumption(Small_Enough(a.cosine));

	s = a;
	Test_Assumption(s == r);

	return true;
}
예제 #5
0
//
//###########################################################################
//###########################################################################
//
bool
	Origin3D::TestClass()
{
	SPEW((GROUP_STUFF_TEST, "Starting Origin3D test..."));

	Point3D p(1.0f,2.0f,3.0f);
	UnitQuaternion q(0.0f, 1.0f, 0.0f, 0.0f);

	UnitQuaternion r;
	r = q;
	const Origin3D
		a(p,r);
	Origin3D
		b;

	UnitQuaternion t;
	t = a.angularPosition;
	Test_Assumption(
		a.linearPosition == p
		 && t.x == q.x
		 && t.w == q.w
	);

	LinearMatrix4D
		m;

	m = a;
	b = m;
	t = b;
	Test_Assumption(
		a.linearPosition == b.linearPosition
		 && t.y == q.y
	);

#if 0
	b = Point3D(3.0f,2.0f,1.0f);
	p = b;
	Test_Assumption(p == Point3D(3.0f,2.0f,1.0f));
#endif

	return true;
}
예제 #6
0
//
//###########################################################################
// TestOrder
//###########################################################################
//
bool
	TreeTestNode::TestOrder()
{
	TreeIteratorOf<TreeTestPlug*, int> iterator1(&tree1);
	TreeIteratorOf<TreeTestPlug*, int> iterator2(&tree2);
	TreeTestPlug *testPlug1, *testPlug2;
	int i, size;

	size = iterator1.GetSize();
	for (i = 1; i < size; i++)
	{
		testPlug1 = iterator1.GetNth(i-1);
		testPlug2 = iterator2.GetNth(i);

		Test_Assumption(testPlug1->value < testPlug2->value);
	}
	return true;
}
예제 #7
0
//
//###########################################################################
//###########################################################################
//
bool
UnitVector3D::TestClass()
{
	SPEW((GROUP_STUFF_TEST, "Starting UnitVector3D test..."));
	UnitVector3D
	b;
	const UnitVector3D
	c(0.6f, 0.0f, 0.8f);
	UnitVector3D
	d(0.8f, -0.6f, 0.0f);
#if 0
	Test_Assumption(c.x == 0.6f && c.y == 0.0f && c.z == 0.8f);
	Test_Assumption(c[2] == c.z);
#endif
	b = c;
#if 0
	Test_Assumption(b.x == c.x && b.y == c.y && b.z == c.z);
#endif
	Test_Assumption(Close_Enough(b, c));
	Test_Assumption(b == c);
	b.Negate(c);
	Test_Assumption(b == UnitVector3D(-c.x, -c.y, -c.z));
	float f = c * d;
	Test_Assumption(Close_Enough(f, c.x * d.x + c.y * d.y + c.z * d.z));
	LinearMatrix4D
	m;
	EulerAngles
	r(Pi_Over_4, 0.0f, 0.0f);
	m.BuildRotation(r);
	b.Multiply(c, m);
	Test_Assumption(b == UnitVector3D(c.x, c.y * m(1, 1) + c.z * m(2, 1), c.y * m(1, 2) + c.z * m(2, 2)));
	b = c;
	b *= m;
	Test_Assumption(b == UnitVector3D(c.x, c.y * m(1, 1) + c.z * m(2, 1), c.y * m(1, 2) + c.z * m(2, 2)));
	f = c.GetLengthSquared();
	Test_Assumption(Close_Enough(f, 1.0f));
	f = c.GetLength();
	Test_Assumption(Close_Enough(f, 1.0f));
	Vector3D v(0.0f, 1.2f, 1.6f);
	f = v.GetLength();
	b = v;
	Test_Assumption(b == UnitVector3D(v.x / f, v.y / f, v.z / f));
	return true;
}
예제 #8
0
//
//#############################################################################
//#############################################################################
//
bool
	Radian::TestClass()
{
	SPEW((GROUP_STUFF_TEST, "Starting Radian Test..."));

	const Radian a(1.25f);
	Radian
		b,c;

	Test_Assumption(a);

	c = 0.0f;
	Test_Assumption(!c);

	Test_Assumption(Normalize(3.1f) == 3.1f);
	Test_Assumption(Normalize(-3.1f) == -3.1f);
	Scalar f = Normalize(Pi+Pi_Over_2);
	Test_Assumption(Close_Enough(f,Pi_Over_2 - Pi));
	f = Normalize(-Pi-Pi_Over_2);
	Test_Assumption(Close_Enough(f,Pi - Pi_Over_2));

	c = a;
#if 0
	Test_Assumption(c			== a);
	Test_Assumption(c.angle	== a);
	Test_Assumption(c			== a.angle);
#endif

	b.Negate(c);
#if 0
	Test_Assumption(b			== -c.angle);
#endif
	#if 0
	b = -c;
	d.Add(b,c);
	Test_Assumption(d			== b.angle + c.angle);
	Test_Assumption(a+b			== a.angle + b.angle);
	Test_Assumption(a+c			== a.angle + c.angle);
	Test_Assumption(a+1.25f	== a.angle+1.25f);
	Test_Assumption(1.25f+c	== 1.25f+c.angle);

	c = 1.5f;
	d.Subtract(c,a);
	Test_Assumption(d			== c.angle - a.angle);
	Test_Assumption(c-a			== c.angle - a.angle);
	Test_Assumption(c-1.25f	== c.angle - 1.25f);
	Test_Assumption(1.5f-a		== 1.5f - a.angle);
	Test_Assumption(c-b			== c.angle - b.angle);

	c = 2.5f;
	d.Multiply(a,c);
	Test_Assumption(d			== a.angle * c.angle);
	Test_Assumption(a*c			== a.angle * c.angle);
	Test_Assumption(1.25f*c	== 1.25f * c.angle);
	Test_Assumption(a*2.5f		== a.angle * 2.5f);
	Test_Assumption(a*b			== a.angle * b.angle);

	c = 2.0f;
	d.Divide(a,c);
	Test_Assumption(d			== a.angle / c.angle);
	Test_Assumption(a/c			== a.angle / c.angle);
	Test_Assumption(1.25f/c	== 1.25f / c.angle);
	Test_Assumption(a/2.0f		== a.angle / 2.0f);
	Test_Assumption(a/b			== a.angle / b.angle);

	b = a;
	b += c;
	b.Normalize();
	Test_Assumption(b == 3.25f - TWO_PI);
	b += 2.0f;
	b.Normalize();
	Test_Assumption(b == 5.25f - TWO_PI);

	b -= c;
	b.Normalize();
	Test_Assumption(b == 3.25f - TWO_PI);
	b -= 2.0f;
	b.Normalize();
	Test_Assumption(b == 1.25f);

	b *= c;
	b.Normalize();
	Test_Assumption(b == 1.25f*2.0f);
	b *= 2.0f;
	b.Normalize();
	Test_Assumption(b == 1.25f*2.0f*2.0f - TWO_PI);

	b = a*c;
	b.Normalize();
	Test_Assumption(b == 1.25f*2.0f);
	b /= 2.0f;
	b.Normalize();
	Test_Assumption(b == 1.25f);

	b = -3.0f*PI_OVER_4;
	c = 3.0f*PI_OVER_4;
	Test_Assumption(Lerp(b,c,0.25f) < b);
	Test_Assumption(Normalize(Lerp(b,c,0.75f)) > c);
	#endif

	return true;
}
예제 #9
0
//
//###########################################################################
// RunTest
//###########################################################################
//
bool
	TreeTestNode::RunTest()
{
	TreeTestPlug	*testPlug1, *testPlug2;
	int		 		values[TEST_COUNT];
	int				i, j;
//	Time 				startTicks;

	/*
	 * Generate unique values, shuffle them
	 */
	for (i = 0; i < TEST_COUNT; i++) {
		values[i] = i;
	}
	for (i = 0; i < TEST_COUNT; i++) {
		int   tmp;
                
		j = i + Random::GetLessThan(TEST_COUNT - i);
		tmp = values[j];
		values[j] = values[i];
		values[i] = tmp;
	}

	//
	//--------------------------------------------------------------------
	// Stress tests
	//--------------------------------------------------------------------
	//

	/*
	 * Create plugs and add to both sockets
	 */
	for (i = 0; i < TEST_COUNT; i++)
	{
		testPlug1 = new TreeTestPlug(values[i]);
		Register_Object(testPlug1);
		tree1.AddValue(testPlug1, values[i]);
		tree2.AddValue(testPlug1, values[i]);
	}
	TestOrder();

	/*
	 * Find
	 */
	{
		for (i = 0; i < TEST_COUNT; i++)
		{
			testPlug1 = tree1.Find(i);
			testPlug2 = tree2.Find(i);

			Test_Assumption( testPlug1->value == i );
			Test_Assumption( testPlug2->value == i );

			Test_Assumption( testPlug1 == testPlug2 );
		}
	}

	/*
	 * Test_Assumption first and last
	 */
	{
		TreeIteratorOf<TreeTestPlug*, int> iterator1(&tree1);
		TreeIteratorOf<TreeTestPlug*, int> iterator2(&tree2);

		Test_Assumption( iterator1.GetSize() == TEST_COUNT );
		Test_Assumption( iterator2.GetSize() == TEST_COUNT );

		iterator1.First();
		iterator2.First();

		testPlug1 = iterator1.GetCurrent();
		testPlug2 = iterator2.GetCurrent();

		Test_Assumption( testPlug1 == testPlug2 );
		Test_Assumption( testPlug1 == iterator1.GetNth(0) );
		Test_Assumption( testPlug1 == iterator2.GetNth(0) );
	}

	/*
	 * Test_Assumption next and prev
	 */
	{
		TreeIteratorOf<TreeTestPlug*, int> iterator1(&tree1);
		TreeIteratorOf<TreeTestPlug*, int> iterator2(&tree2);

		Test_Assumption( iterator1.GetSize() == TEST_COUNT );
		Test_Assumption( iterator2.GetSize() == TEST_COUNT );

		i = 0;
		while ((testPlug1 = iterator1.GetCurrent()) != NULL)
		{
			testPlug2 = iterator2.GetCurrent();

			Test_Assumption( testPlug1 == testPlug2 );

			Test_Assumption( testPlug1->value == i );
			Test_Assumption( testPlug2->value == i );

			iterator1.Next();
			iterator2.Next();

			i++;
		}
		Test_Assumption( i == TEST_COUNT );
	}

	/*
	 * Test_Assumption read next and read prev
	 */
	{
		TreeIteratorOf<TreeTestPlug*, int> iterator1(&tree1);
		TreeIteratorOf<TreeTestPlug*, int> iterator2(&tree2);

		Test_Assumption( iterator1.GetSize() == TEST_COUNT );
		Test_Assumption( iterator2.GetSize() == TEST_COUNT );

		i = 0;
		while ((testPlug1 = iterator1.ReadAndNext()) != NULL)
		{
			testPlug2 = iterator2.ReadAndNext();

			Test_Assumption( testPlug1 == testPlug2 );

			Test_Assumption( testPlug1->value == i );
			Test_Assumption( testPlug2->value == i );

			i++;
		}
		Test_Assumption( i == TEST_COUNT );
	}

	/*
	 * Test_Assumption nth
	 */
	{
		TreeIteratorOf<TreeTestPlug*, int> iterator1(&tree1);
		TreeIteratorOf<TreeTestPlug*, int> iterator2(&tree2);

		Test_Assumption( iterator1.GetSize() == TEST_COUNT );
		Test_Assumption( iterator2.GetSize() == TEST_COUNT );

		for (i = 0; i < TEST_COUNT; i++)
		{
			testPlug1 = iterator1.GetNth(i);
			testPlug2 = iterator2.GetNth(i);

			Test_Assumption( testPlug1 == testPlug2 );

			Test_Assumption( testPlug1->value == i );
			Test_Assumption( testPlug2->value == i );
		}
	}

	/*
	 * Test_Assumption Remove
	 */
	{
		TreeIteratorOf<TreeTestPlug*, int> iterator1(&tree1);
		TreeIteratorOf<TreeTestPlug*, int> iterator2(&tree2);

		Test_Assumption( iterator1.GetSize() == TEST_COUNT );
		Test_Assumption( iterator2.GetSize() == TEST_COUNT );

		i = 0;
		while ((testPlug1 = iterator1.GetCurrent()) != NULL)
		{
			Test_Assumption( testPlug1->value == i );

			iterator1.Remove();

			testPlug2 = iterator2.GetNth(0);

			Test_Assumption( testPlug2->value == i );
			Test_Assumption( testPlug1 == testPlug2 );

			Unregister_Object(testPlug2);
			delete testPlug2;

			i++;
			TestOrder();
		}
		Test_Assumption( i == TEST_COUNT );
		Test_Assumption( iterator1.GetSize() == 0 );
		Test_Assumption( iterator2.GetSize() == 0 );
	}

	/*
	 * Test_Assumption random deletion
	 */
	/*
	 * Add plugs to both sockets
	 */
	{
		TreeIteratorOf<TreeTestPlug*, int> iterator1(&tree1);
		TreeIteratorOf<TreeTestPlug*, int> iterator2(&tree2);

		Test_Assumption( iterator1.GetSize() == 0 );
		Test_Assumption( iterator2.GetSize() == 0 );

		for (i = 0; i < TEST_COUNT; i++)
		{
			testPlug1 = new TreeTestPlug(values[i]);
			Register_Object( testPlug1 );
			tree1.AddValue(testPlug1, values[i]);
			tree2.AddValue(testPlug1, values[i]);

			TestOrder();
		}
		TestOrder();
	}

	/*
	 * Perform random deletion
	 */
	{
		int size, index;
		TreeIteratorOf<TreeTestPlug*, int> iterator1(&tree1);
		TreeIteratorOf<TreeTestPlug*, int> iterator2(&tree2);

		Test_Assumption( iterator1.GetSize() == TEST_COUNT );
		Test_Assumption( iterator2.GetSize() == TEST_COUNT );

		i = 0;
		while((size = iterator1.GetSize()) != 0)
		{
			index = Random::GetLessThan(size);
			testPlug1 = iterator1.GetNth(index);
			iterator1.Remove();

			testPlug2 = iterator2.GetNth(index);
			Test_Assumption( testPlug1 == testPlug2 );

			Unregister_Object( testPlug2 );
			delete(testPlug2);

			i++;
			TestOrder();
		}
		Test_Assumption( i == TEST_COUNT );
		Test_Assumption( iterator1.GetSize() == 0 );
		Test_Assumption( iterator2.GetSize() == 0 );
	}
	return true;
}
예제 #10
0
//
//###########################################################################
// RunProfile
//###########################################################################
//
bool
	TreeTestNode::RunProfile()
{
	TreeTestPlug	*testPlug1, *testPlug2;
	int			 	values[TEST_COUNT];
	int				i, j;
	Time 				startTicks;

	/*
	 * Generate unique values, shuffle them
	 */
	for (i = 0; i < TEST_COUNT; i++) {
		values[i] = i;
	}
	for (i = 0; i < TEST_COUNT; i++) {
		int   tmp;
                
		j = i + Random::GetLessThan(TEST_COUNT - i);
		tmp = values[j];
		values[j] = values[i];
		values[i] = tmp;
	}

	//
	//--------------------------------------------------------------------
	// Run timing tests
	//--------------------------------------------------------------------
	//

	/*
	 * Create plugs and add to both sockets
	 */
	startTicks = gos_GetHiResTime();
	for (i = 0; i < TEST_COUNT; i++) 
	{
		testPlug1 = new TreeTestPlug(values[i]);
		Register_Object( testPlug1 );
		tree1.AddValue(testPlug1, values[i]);
		tree2.AddValue(testPlug1, values[i]);
	}
	SPEW((
		GROUP_STUFF_TEST,
		"TreeTestNode::RunTest Create = %f",
		gos_GetHiResTime() - startTicks
	));

	/*
	 * Iterate over both sockets
	 */
	startTicks = gos_GetHiResTime();
	{
		TreeIteratorOf<TreeTestPlug*, int> iterator1(&tree1);
		TreeIteratorOf<TreeTestPlug*, int> iterator2(&tree2);

		Test_Assumption( iterator1.GetSize() == TEST_COUNT );
		Test_Assumption( iterator2.GetSize() == TEST_COUNT );
		
		i = 0;
		while ((testPlug1 = iterator1.ReadAndNext()) != NULL)
		{
			Test_Assumption( testPlug1->value == i );
			i++;
		}
		Test_Assumption( i == TEST_COUNT );
		
		i = 0;
		while ((testPlug1 = iterator2.ReadAndNext()) != NULL)
		{
			Test_Assumption( testPlug1->value == i );
			i++;
		}
		Test_Assumption( i == TEST_COUNT );
	}
	SPEW((
		GROUP_STUFF_TEST,
		"TreeTestNode::RunTest Iterate = %f",
		gos_GetHiResTime() - startTicks
	));

	/*
	 * Find 
	 */
	startTicks = gos_GetHiResTime();
	{
		TreeIteratorOf<TreeTestPlug*, int> iterator1(&tree1);
		TreeIteratorOf<TreeTestPlug*, int> iterator2(&tree2);

		for (i = 0; i < TEST_COUNT; i++) 
		{
			testPlug1 = iterator1.Find(i);
			testPlug2 = iterator2.Find(i);

			Test_Assumption( testPlug1->value == i );
			Test_Assumption( testPlug2->value == i );

			Test_Assumption( testPlug1 == testPlug2 );
		}
	}
	SPEW((
		GROUP_STUFF_TEST,
		"TreeTestNode::RunTest Find = %f",
		gos_GetHiResTime() - startTicks
	));

	/*
	 * Destroy from tree1, verify with tree2
	 */
	startTicks = gos_GetHiResTime();
	{
		TreeIteratorOf<TreeTestPlug*, int> iterator1(&tree1);
		TreeIteratorOf<TreeTestPlug*, int> iterator2(&tree2);

		Test_Assumption( iterator1.GetSize() == TEST_COUNT );
		Test_Assumption( iterator2.GetSize() == TEST_COUNT );

		i = 0;
		while ((testPlug1 = iterator1.ReadAndNext()) != NULL)
		{
			Test_Assumption( testPlug1->value == i );
			i++;
			
			Unregister_Object(testPlug1);
			delete(testPlug1);
		}
		Test_Assumption( i == TEST_COUNT );
		
		Test_Assumption( iterator1.GetSize() == 0 );
		Test_Assumption( iterator2.GetSize() == 0 );
	}
	SPEW((
		GROUP_STUFF_TEST,
		"TreeTestNode::RunTest Destroy = %f",
		gos_GetHiResTime() - startTicks
	));
	return true;
}
예제 #11
0
bool
	SafeChainTestNode::RunProfile()
{
	SafeChainTestPlug	*testPlug1;
	int 				i;
	Time 		startTicks;

	//
	//--------------------------------------------------------------------
	// Run timing tests
	//--------------------------------------------------------------------
	//

	/*
	 * Create plugs and add to both sockets
	 */
	startTicks = gos_GetHiResTime();
	for (i = 0; i < TEST_COUNT; i++) 
	{
		testPlug1 = new SafeChainTestPlug(i);
		Register_Object( testPlug1 );
		chain1.Add(testPlug1);
		chain2.Add(testPlug1);
	}
	SPEW((
		GROUP_STUFF_TEST,
		"SafeChainTestNode::RunTest Create = %f",
		gos_GetHiResTime() - startTicks
	));

	/*
	 * Iterate over both sockets
	 */
	startTicks = gos_GetHiResTime();
	{
		SafeChainIteratorOf<SafeChainTestPlug*> iterator1(&chain1);
		SafeChainIteratorOf<SafeChainTestPlug*> iterator2(&chain2);
	
		Test_Assumption( iterator1.GetSize() == TEST_COUNT );
		Test_Assumption( iterator2.GetSize() == TEST_COUNT );
		
		i = 0;
		while ((testPlug1 = iterator1.ReadAndNext()) != NULL)
		{
			Test_Assumption( testPlug1->value == i );
			i++;
		}
		Test_Assumption( i == TEST_COUNT );
		
		i = 0;
		while ((testPlug1 = iterator2.ReadAndNext()) != NULL)
		{
			Test_Assumption( testPlug1->value == i );
			i++;
		}
		Test_Assumption( i == TEST_COUNT );
	}
	SPEW((
		GROUP_STUFF_TEST,
		"SafeChainTestNode::RunTest Iterate = %f",
		gos_GetHiResTime() - startTicks
	));

	/*
	 * Destroy from chain1, verify with chain2
	 */
	startTicks = gos_GetHiResTime();
	{
		SafeChainIteratorOf<SafeChainTestPlug*> iterator1(&chain1);
		SafeChainIteratorOf<SafeChainTestPlug*> iterator2(&chain2);

		Test_Assumption( iterator1.GetSize() == TEST_COUNT );
		Test_Assumption( iterator2.GetSize() == TEST_COUNT );

		i = 0;
		while ((testPlug1 = iterator1.ReadAndNext()) != NULL)
		{
			Test_Assumption( testPlug1->value == i );
			i++;
			
			Unregister_Object( testPlug1 );
			delete(testPlug1);
		}
		Test_Assumption( i == TEST_COUNT );
		
		Test_Assumption( iterator1.GetSize() == 0 );
		Test_Assumption( iterator2.GetSize() == 0 );
	}
	SPEW((
		GROUP_STUFF_TEST,
		"SafeChainTestNode::RunTest Destroy = %f",
		gos_GetHiResTime() - startTicks
	));
	return true;
}
예제 #12
0
bool
	SafeChainTestNode::RunTest()
{
	SafeChainTestPlug	*testPlug1, *testPlug2;
	int 			i, j;
//	Time 		startTicks;

	//
	//--------------------------------------------------------------------
	// Stress tests
	//--------------------------------------------------------------------
	//

	/*
	 * Create plugs and add to both sockets
	 */
	for (i = 0; i < TEST_COUNT; i++) 
	{
		testPlug1 = new SafeChainTestPlug(i);
		Register_Object( testPlug1 );
		chain1.Add(testPlug1);
		chain2.Add(testPlug1);
	}

	/*
	 * Test_Assumption first and last
	 */
	{
		SafeChainIteratorOf<SafeChainTestPlug*> iterator1(&chain1);
		SafeChainIteratorOf<SafeChainTestPlug*> iterator2(&chain2);

		Test_Assumption( iterator1.GetSize() == TEST_COUNT );
		Test_Assumption( iterator2.GetSize() == TEST_COUNT );

		iterator1.First();
		iterator2.First();
		
		testPlug1 = iterator1.GetCurrent();
		testPlug2 = iterator2.GetCurrent();

		Test_Assumption( testPlug1 == testPlug2 );
		Test_Assumption( testPlug1 == iterator1.GetNth(0) );
		Test_Assumption( testPlug1 == iterator2.GetNth(0) );

		iterator1.Last();
		iterator2.Last();
		
		testPlug1 = iterator1.GetCurrent();
		testPlug2 = iterator2.GetCurrent();

		Test_Assumption( testPlug1 == testPlug2 );
		Test_Assumption( testPlug1 == iterator1.GetNth(TEST_COUNT - 1) );
		Test_Assumption( testPlug1 == iterator2.GetNth(TEST_COUNT - 1) );
	}

	/*
	 * Test_Assumption next and prev
	 */
	{
		SafeChainIteratorOf<SafeChainTestPlug*> iterator1(&chain1);
		SafeChainIteratorOf<SafeChainTestPlug*> iterator2(&chain2);
	
		Test_Assumption( iterator1.GetSize() == TEST_COUNT );
		Test_Assumption( iterator2.GetSize() == TEST_COUNT );
		
		i = 0;
		while ((testPlug1 = iterator1.GetCurrent()) != NULL)
		{
			testPlug2 = iterator2.GetCurrent();
			
			Test_Assumption( testPlug1 == testPlug2 );

			Test_Assumption( testPlug1->value == i );
			Test_Assumption( testPlug2->value == i );
			
			iterator1.Next();
			iterator2.Next();

			i++;
		}
		Test_Assumption( i == TEST_COUNT );

		iterator1.Last();
		iterator2.Last();

		i = TEST_COUNT - 1;
		while ((testPlug1 = iterator1.GetCurrent()) != NULL)
		{
			testPlug2 = iterator2.GetCurrent();
			
			Test_Assumption( testPlug1 == testPlug2 );

			Test_Assumption( testPlug1->value == i );
			Test_Assumption( testPlug2->value == i );
			
			iterator1.Previous();
			iterator2.Previous();
			
			i--;
		}
		Test_Assumption( i == -1 );
	}

	/*
	 * Test_Assumption read next and read prev
	 */
	{
		SafeChainIteratorOf<SafeChainTestPlug*> iterator1(&chain1);
		SafeChainIteratorOf<SafeChainTestPlug*> iterator2(&chain2);
	
		Test_Assumption( iterator1.GetSize() == TEST_COUNT );
		Test_Assumption( iterator2.GetSize() == TEST_COUNT );
		
		i = 0;
		while ((testPlug1 = iterator1.ReadAndNext()) != NULL)
		{
			testPlug2 = iterator2.ReadAndNext();
			
			Test_Assumption( testPlug1 == testPlug2 );

			Test_Assumption( testPlug1->value == i );
			Test_Assumption( testPlug2->value == i );
			
			i++;
		}
		Test_Assumption( i == TEST_COUNT );

		iterator1.Last();
		iterator2.Last();

		i = TEST_COUNT - 1;
		while ((testPlug1 = iterator1.ReadAndPrevious()) != NULL)
		{
			testPlug2 = iterator2.ReadAndPrevious();
			
			Test_Assumption( testPlug1 == testPlug2 );

			Test_Assumption( testPlug1->value == i );
			Test_Assumption( testPlug2->value == i );

			i--;
		}
		Test_Assumption( i == -1 );
	}
	
	/*
	 * Test_Assumption nth
	 */
	{
		SafeChainIteratorOf<SafeChainTestPlug*> iterator1(&chain1);
		SafeChainIteratorOf<SafeChainTestPlug*> iterator2(&chain2);
	
		Test_Assumption( iterator1.GetSize() == TEST_COUNT );
		Test_Assumption( iterator2.GetSize() == TEST_COUNT );
		
		for (i = 0; i < TEST_COUNT; i++) 
		{
			testPlug1 = iterator1.GetNth(i);
			testPlug2 = iterator2.GetNth(i);
			
			Test_Assumption( testPlug1 == testPlug2 );

			Test_Assumption( testPlug1->value == i );
			Test_Assumption( testPlug2->value == i );
		}
	}

	/*
	 * Test_Assumption Remove
	 */
	{
		SafeChainIteratorOf<SafeChainTestPlug*> iterator1(&chain1);
		SafeChainIteratorOf<SafeChainTestPlug*> iterator2(&chain2);
	
		Test_Assumption( iterator1.GetSize() == TEST_COUNT );
		Test_Assumption( iterator2.GetSize() == TEST_COUNT );

		i = 0;
		while ((testPlug1 = iterator1.GetCurrent()) != NULL)
		{
			Test_Assumption( testPlug1->value == i );

			iterator1.Remove();
			
			testPlug2 = iterator2.GetNth(0);
			
			Test_Assumption( testPlug2->value == i );
			Test_Assumption( testPlug1 == testPlug2 );
			
			Unregister_Object( testPlug2 );
			delete(testPlug2);
			
			i++;
		}
		Test_Assumption( i == TEST_COUNT );
		Test_Assumption( iterator1.GetSize() == 0 );
		Test_Assumption( iterator2.GetSize() == 0 );
	}

	/*
	 * Test_Assumption random deletion
	 */
	{
		/*
		 * Add plugs to both sockets
		 */
		SafeChainIteratorOf<SafeChainTestPlug*> iterator1(&chain1);
		SafeChainIteratorOf<SafeChainTestPlug*> iterator2(&chain2);

		Test_Assumption( iterator1.GetSize() == 0 );
		Test_Assumption( iterator2.GetSize() == 0 );

		for (i = 0; i < TEST_COUNT; i++)
		{
			testPlug1 = new SafeChainTestPlug(i);
			Register_Object( testPlug1 );
			chain1.Add(testPlug1);
			chain2.Add(testPlug1);
		}
	}

	{
		/*
		 * Perform random deletion
		 */
		int size, index;
		SafeChainIteratorOf<SafeChainTestPlug*> iterator1(&chain1);
		SafeChainIteratorOf<SafeChainTestPlug*> iterator2(&chain2);

		Test_Assumption( iterator1.GetSize() == TEST_COUNT );
		Test_Assumption( iterator2.GetSize() == TEST_COUNT );

		i = 0;
		while((size = iterator1.GetSize()) != 0)
		{
			index = Random::GetLessThan(size);
			testPlug1 = iterator1.GetNth(index);
			iterator1.Remove();

			testPlug2 = iterator2.GetNth(index);
			Test_Assumption( testPlug1 == testPlug2 );

			Unregister_Object( testPlug2 );
			delete(testPlug2);

			i++;
		}
		Test_Assumption( i == TEST_COUNT );
		Test_Assumption( iterator1.GetSize() == 0 );
		Test_Assumption( iterator2.GetSize() == 0 );
	}

	/*
	 * Test_Assumption insertion
	 */
	{
		SafeChainIteratorOf<SafeChainTestPlug*> iterator1(&chain1);

		Test_Assumption(iterator1.GetSize() == 0);

		for (i = 0; i < TEST_COUNT; i++)
		{
			testPlug1 = new SafeChainTestPlug(i);
			Register_Object(testPlug1);

			if (i == 0)
			{
				chain1.Add(testPlug1);
			}
			else
			{
				iterator1.First();
				iterator1.Insert(testPlug1);
			}
		}

		for (i = 0, j = TEST_COUNT-1; i < TEST_COUNT; i++, j--)
		{
			testPlug1 = iterator1.GetNth(i);
			Test_Assumption(testPlug1->value == j);
		}

      iterator1.DeletePlugs();
	}
	{
		SafeChainIteratorOf<SafeChainTestPlug*> iterator1(&chain1);

		Test_Assumption(iterator1.GetSize() == 0);

		for (i = 0; i < TEST_COUNT; i++)
		{
			testPlug1 = new SafeChainTestPlug(i);
			Register_Object(testPlug1);

			if (i == 0)
			{
				chain1.Add(testPlug1);
			}
			else
			{
				iterator1.Last();
				iterator1.Insert(testPlug1);
			}
		}

		for (i = 0; i < TEST_COUNT; i++)
		{
			testPlug1 = iterator1.GetNth(i);
			if (i == TEST_COUNT-1)
			{
				Test_Assumption(testPlug1->value == 0);
			}
			else
			{
				Test_Assumption(testPlug1->value == i+1);
			}
		}

      iterator1.DeletePlugs();
	}
	return true;
}