//===========================================================================// // File: rect2d.tst // // Project: MUNGA Brick: Math Library // // Contents: Test code for two-dimensional rectangle class // //---------------------------------------------------------------------------// // Date Who Modification // // -------- --- ---------------------------------------------------------- // // 2/01/94 CPB Initial coding (copied from vector3d.tst) // //---------------------------------------------------------------------------// // Copyright (C) 1994-1995, Virtual World Entertainment, Inc. // // All Rights reserved worldwide // // This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL // //===========================================================================// // //########################################################################### //########################################################################### // Logical Rectangle2D::TestClass() { DEBUG_STREAM << "Starting Rectangle2D test...\n"; // //------------------------------------------------------------------- // Constructors (and IsEmpty()) //------------------------------------------------------------------- // { Vector2DOf v1(0,0), v2(1,1); Rectangle2D a; Check(&a); Test(a.IsEmpty()); Rectangle2D b(v1,v2); Check(&b); Test(!b.IsEmpty()); Test(b.bottomLeft == v1); Test(b.topRight == v2); Rectangle2D c(0,1,2,3); Check(&c); Test(!c.IsEmpty()); Test(c.bottomLeft.x == 0); Test(c.bottomLeft.y == 1); Test(c.topRight.x == 2); Test(c.topRight.y == 3); } // //------------------------------------------------------------------- // Union //------------------------------------------------------------------- // { Rectangle2D a; Rectangle2D b(0,0,2,2); Rectangle2D c(1,1,3,3); Rectangle2D d(10,10,11,11); Rectangle2D e(2,3,4,5); e.Union(a,a); Test(e.IsEmpty()); e.Union(a,b); Test(e.bottomLeft == b.bottomLeft); Test(e.topRight == b.topRight); e.Union(b,a); Test(e.bottomLeft == b.bottomLeft); Test(e.topRight == b.topRight); e.Union(b,c); Test(e.bottomLeft == b.bottomLeft); Test(e.topRight == c.topRight); e.Union(c,b); Test(e.bottomLeft == b.bottomLeft); Test(e.topRight == c.topRight); e.Union(b,d); Test(e.bottomLeft == b.bottomLeft); Test(e.topRight == d.topRight); e.Union(d,b); Test(e.bottomLeft == b.bottomLeft); Test(e.topRight == d.topRight); } // //------------------------------------------------------------------- // Intersection //------------------------------------------------------------------- // { Rectangle2D a; Rectangle2D b(0,0,2,2); Rectangle2D c(1,1,3,3); Rectangle2D d(10,10,11,11); Rectangle2D e(2,3,4,5); e.Intersection(a,a); Test(e.IsEmpty()); e.Intersection(a,b); Test(e.IsEmpty()); e.Intersection(b,a); Test(e.IsEmpty()); e.Intersection(b,c); Test(e.bottomLeft == c.bottomLeft); Test(e.topRight == b.topRight); e.Intersection(c,b); Test(e.bottomLeft == c.bottomLeft); Test(e.topRight == b.topRight); e.Intersection(b,d); Test(e.IsEmpty()); e.Intersection(d,b); Test(e.IsEmpty()); } return True; }