TEST(HitPointInterval, ShouldComputeIntersectionOfEmptyAndNonEmptyIntervals) {
   HitPointInterval interval1, interval2;
   HitPoint hitPoint(box, 5, Vector3d(), Vector3d());
   interval2.add(hitPoint);
   HitPointInterval intersectionInterval = interval1 & interval2;
   ASSERT_TRUE(intersectionInterval.min() == HitPoint::undefined());
   ASSERT_TRUE(intersectionInterval.max() == HitPoint::undefined());
 }
 TEST(HitPointInterval, ShouldComputeUnionOfEmptyAndNonEmptyIntervals) {
   HitPointInterval interval1, interval2;
   HitPoint hitPoint(box, 5, Vector3d(), Vector3d());
   interval2.add(hitPoint);
   HitPointInterval unionInterval = interval1 | interval2;
   
   ASSERT_TRUE(unionInterval.min() == hitPoint);
   ASSERT_TRUE(unionInterval.max() == hitPoint);
 }
 TEST(HitPointInterval, ShouldComputeCompositeOfIntervals) {
   HitPointInterval interval1, interval2;
   HitPoint hitPoint1(box, 2, Vector3d(), Vector3d());
   HitPoint hitPoint2(box, 3, Vector3d(), Vector3d());
   HitPoint hitPoint3(box, 4, Vector3d(), Vector3d());
   HitPoint hitPoint4(box, 5, Vector3d(), Vector3d());
   interval1.add(hitPoint1, hitPoint2);
   interval2.add(hitPoint3, hitPoint4);
   HitPointInterval compositeInterval = interval1 + interval2;
   
   ASSERT_TRUE(compositeInterval.min() == hitPoint1);
   ASSERT_TRUE(compositeInterval.max() == hitPoint4);
 }
 TEST(HitPointInterval, ShouldReturnEmptyIntersectionIfIntervalsDontOverlap) {
   HitPointInterval interval1, interval2;
   HitPoint hitPoint1(box, 2, Vector3d(), Vector3d());
   HitPoint hitPoint2(box, 3, Vector3d(), Vector3d());
   HitPoint hitPoint3(box, 4, Vector3d(), Vector3d());
   HitPoint hitPoint4(box, 5, Vector3d(), Vector3d());
   interval1.add(hitPoint1, hitPoint2);
   interval2.add(hitPoint3, hitPoint4);
   HitPointInterval intersectionInterval = interval1 & interval2;
   
   ASSERT_TRUE(intersectionInterval.min() == HitPoint::undefined());
   ASSERT_TRUE(intersectionInterval.max() == HitPoint::undefined());
 }
 TEST(HitPointInterval, ShouldComputeIntersectionOfTwoNonEmptyIntervals) {
   HitPointInterval interval1, interval2;
   HitPoint hitPoint1(box, 2, Vector3d(), Vector3d());
   HitPoint hitPoint2(box, 5, Vector3d(), Vector3d());
   HitPoint hitPoint3(box, 4, Vector3d(), Vector3d());
   HitPoint hitPoint4(box, 7, Vector3d(), Vector3d());
   interval1.add(hitPoint1, hitPoint2);
   interval2.add(hitPoint3, hitPoint4);
   HitPointInterval intersectionInterval = interval1 & interval2;
   
   ASSERT_TRUE(intersectionInterval.min() == hitPoint3);
   ASSERT_TRUE(intersectionInterval.max() == hitPoint2);
 }
 TEST(HitPointInterval, ShouldComputeMergedInterval) {
   HitPointInterval interval;
   HitPoint hitPoint1(box, 2, Vector3d(), Vector3d());
   HitPoint hitPoint2(box, 3, Vector3d(), Vector3d());
   HitPoint hitPoint3(box, 4, Vector3d(), Vector3d());
   HitPoint hitPoint4(box, 5, Vector3d(), Vector3d());
   interval.add(hitPoint1, hitPoint2);
   interval.add(hitPoint3, hitPoint4);
   
   interval = interval.merged();
   ASSERT_EQ(2ul, interval.points().size());
   ASSERT_TRUE(interval.min() == hitPoint1);
   ASSERT_TRUE(interval.max() == hitPoint4);
 }
 TEST(HitPointInterval, ShouldComputeIntersectionOfTwoEmptyIntervals) {
   HitPointInterval interval1, interval2;
   HitPointInterval intersectionInterval = interval1 & interval2;
   ASSERT_TRUE(intersectionInterval.min() == HitPoint::undefined());
   ASSERT_TRUE(intersectionInterval.max() == HitPoint::undefined());
 }
 TEST(HitPointInterval, ShouldSetClosestAndFarthestHitPointWhenOnlyOneHitPointIsAdded) {
   HitPointInterval interval;
   HitPoint hitPoint(box, 5, Vector3d(), Vector3d());
   interval.add(hitPoint);
   ASSERT_TRUE(interval.min() == interval.max());
 }
 TEST(HitPointInterval, ShouldReturnFarthestHitPoint) {
   HitPointInterval interval;
   HitPoint hitPoint(box, 5, Vector3d(), Vector3d());
   interval.add(hitPoint);
   ASSERT_TRUE(hitPoint == interval.max());
 }
Esempio n. 10
0
 TEST(HitPointInterval, ShouldReturnUndefinedFarthestHitPointOnEmptyInterval) {
   HitPointInterval interval;
   const HitPoint& i = interval.max();
   ASSERT_TRUE(i == HitPoint::undefined());
 }