TEST(BoundingBox, Intersection){
	Point lb(1,2,0);
	Point ub(2,4,0);
	BoundingBox bb1(lb, ub);
	BoundingBox bb2(lb, ub);

	// Intersection should return an bounding box equal to bb2 and bb1,
	// they are the same bb
	BoundingBox bbIntersection = bb2.intersection(bb1);
	EXPECT_TRUE( bbIntersection.getLb().getX() == bb2.getLb().getX() &&
				bbIntersection.getLb().getY() == bb2.getLb().getY() &&
				bbIntersection.getLb().getZ() == bb2.getLb().getZ());

	EXPECT_TRUE( bbIntersection.getUb().getX() == bb2.getUb().getX() &&
				bbIntersection.getUb().getY() == bb2.getUb().getY() &&
				bbIntersection.getUb().getZ() == bb2.getUb().getZ());

	Point lb3(2,3,0);
	Point ub3(2,4,0);
	BoundingBox bb3(lb3, ub3);
	bbIntersection = bb2.intersection(bb3);
	// lower bound is the value of of bb3
	EXPECT_TRUE( bbIntersection.getLb().getX() == lb3.getX() &&
				bbIntersection.getLb().getY() == lb3.getY() &&
				bbIntersection.getLb().getZ() == lb3.getZ());

	// upper bound should not change
	EXPECT_TRUE( bbIntersection.getUb().getX() == bb2.getUb().getX() &&
				bbIntersection.getUb().getY() == bb2.getUb().getY() &&
				bbIntersection.getUb().getZ() == bb2.getUb().getZ());

}
int main() {
  
  dump();

  for (int i=0;i<500;i++) {
    {
      flop = !flop;
      blockWipedPool().wipe();
      if (i%10==0)  blockWipedPool().clear();
      BP b1(new A1);
      BP b2(new A2);
      BP b3(new A3);
      dump();
      {
	BP bb1(b1->clone());
	BP bb2(b2->clone());
	BP bb3(b3->clone());
	dump();
      }
      dump("after clone destr");
      
      BP b11(new A1);
      BP b22(new A2);
      BP b23(new A2);
      dump();
      b1.reset();
      b2.reset();
      b3.reset();
      dump("after first destr");
    }
    dump();
    { 
      std::vector<BP> v(233);
      for_each(v.begin(),v.end(),&gen);
      dump("after 233 alloc");
      v.resize(123);
      dump("after 110 distr");
    }
    dump();
    
    for (int i=0;i<3;i++){
      std::vector<BP> v(2432);
      for_each(v.begin(),v.end(),&gen);
      std::vector<BP> v1(3213);
      for_each(v1.begin(),v1.end(),&gen);
      {
	std::vector<BP> d; d.swap(v);
      }
      // alloc disalloc
      std::vector<BP> vs(514);
      for_each(vs.begin(),vs.end(),&gen);
      for_each(vs.begin(),vs.end(),&gen);
    }
    dump("loop end");
  }
  return 0;
}