#include "RegionConstruction.h"
#include <Region.h>
#include <Rect.h>
#include <assert.h>
RegionConstruction::RegionConstruction(std::string name) :
RegionTestcase(name)
{
}
RegionConstruction::~RegionConstruction()
{
}
void RegionConstruction::testOneRegion(BRegion *testRegion)
{
assert(!testRegion->RectAt(-1).IsValid());
assert(!testRegion->RectAt(testRegion->CountRects()).IsValid());
BRegion tempRegion1(*testRegion);
assert(RegionsAreEqual(&tempRegion1, testRegion));
CheckFrame(&tempRegion1);
tempRegion1.MakeEmpty();
assert(RegionIsEmpty(&tempRegion1));
CheckFrame(&tempRegion1);
if (!RegionIsEmpty(testRegion)) {
assert(!RegionsAreEqual(&tempRegion1, testRegion));
for(int i = testRegion->CountRects() - 1; i >= 0; i--) {
tempRegion1.Include(testRegion->RectAt(i));
CheckFrame(&tempRegion1);
}
}
assert(RegionsAreEqual(&tempRegion1, testRegion));
if (!RegionIsEmpty(testRegion)) {
BRegion tempRegion2(testRegion->RectAt(0));
CheckFrame(&tempRegion2);
assert(!RegionIsEmpty(&tempRegion2));
BRegion tempRegion3;
CheckFrame(&tempRegion3);
assert(RegionIsEmpty(&tempRegion3));
tempRegion3.Set(testRegion->RectAt(0));
CheckFrame(&tempRegion3);
assert(!RegionIsEmpty(&tempRegion3));
tempRegion1.Set(testRegion->RectAt(0));
CheckFrame(&tempRegion1);
assert(!RegionIsEmpty(&tempRegion1));
assert(RegionsAreEqual(&tempRegion1, &tempRegion2));
assert(RegionsAreEqual(&tempRegion1, &tempRegion3));
assert(RegionsAreEqual(&tempRegion2, &tempRegion3));
}
}
void RegionConstruction::testTwoRegions(BRegion *testRegionA, BRegion *testRegionB)
{
BRegion tempRegion1;
CheckFrame(&tempRegion1);
assert(RegionIsEmpty(&tempRegion1));
tempRegion1 = *testRegionA;
CheckFrame(&tempRegion1);
assert(RegionsAreEqual(&tempRegion1, testRegionA));
tempRegion1 = *testRegionB;
CheckFrame(&tempRegion1);
assert(RegionsAreEqual(&tempRegion1, testRegionB));
tempRegion1.MakeEmpty();
CheckFrame(&tempRegion1);
assert(RegionIsEmpty(&tempRegion1));
}
Test *RegionConstruction::suite(void)
{
typedef CppUnit::TestCaller<RegionConstruction>
RegionConstructionCaller;
return(new RegionConstructionCaller("BRegion::Construction Test", &RegionConstruction::PerformTest));
}