Thursday, July 10, 2008

Progress report 10 July (2)

Made a quick test application that worked well. The following code is written with wrappers and works properly:

Double pi = 3.14159265358979323846;
private bool TestCircleClass()
{
// Create an indefinite circle
OCgp_Circ circ = new OCgp_Circ();
Double radius = 10.0;
Double calculusError = 0.5;

// test the radius methods
circ.SetRadius(radius);
if (Math.Abs(radius - circ.Radius()) > calculusError)
{
return false;
}

// test the length
if (Math.Abs(2 * pi * radius - circ.Length()) > calculusError)
{
return false;
}
// test the area
if (Math.Abs(pi * radius * radius - circ.Area()) > calculusError)
{
return false;
}

// test location
OCgp_Pnt p = new OCgp_Pnt(100, 200, 300);
circ.SetLocation(p);
OCgp_Pnt internalPnt = circ.Location();
if ((p.X() != internalPnt.X()) || (p.Y() != internalPnt.Y()) || (p.Z() != internalPnt.Z()))
{
return false;
}

Console.WriteLine("Circle tests OK");
return true;
}

No comments: