diff --git a/include/OpenSpaceToolkit/Mathematics/Object/Interval.hpp b/include/OpenSpaceToolkit/Mathematics/Object/Interval.hpp index c0cc8b67..ac959847 100644 --- a/include/OpenSpaceToolkit/Mathematics/Object/Interval.hpp +++ b/include/OpenSpaceToolkit/Mathematics/Object/Interval.hpp @@ -354,6 +354,10 @@ class Interval : public IntervalBase static types::String StringFromType(const Interval::Type& anIntervalType); private: + bool contains(const T& aValue, const bool& isOpen) const; + bool checkAgainstLowerBound(const T& aValue, const bool& isOpen, const bool& isUpperBound) const; + bool checkAgainstUpperBound(const T& aValue, const bool& isOpen, const bool& isLowerBound) const; + Interval::Type type_; T lowerBound_; diff --git a/src/OpenSpaceToolkit/Mathematics/Object/Interval.tpp b/src/OpenSpaceToolkit/Mathematics/Object/Interval.tpp index 90df8b0d..4bba0aec 100644 --- a/src/OpenSpaceToolkit/Mathematics/Object/Interval.tpp +++ b/src/OpenSpaceToolkit/Mathematics/Object/Interval.tpp @@ -81,8 +81,33 @@ bool Interval::intersects(const Interval& anInterval) const throw ostk::core::error::runtime::Undefined("Interval"); } - return this->contains(anInterval.lowerBound_) || this->contains(anInterval.upperBound_) || - anInterval.contains(lowerBound_) || anInterval.contains(upperBound_) || (*this) == anInterval; + if (!anInterval.isDefined()) + { + throw ostk::core::error::runtime::Undefined("Interval"); + } + + return ( + (this->checkAgainstLowerBound( + anInterval.lowerBound_, + anInterval.type_ == Interval::Type::Open || anInterval.type_ == Interval::Type::HalfOpenLeft, + false + ) || + this->checkAgainstLowerBound( + anInterval.upperBound_, + anInterval.type_ == Interval::Type::Open || anInterval.type_ == Interval::Type::HalfOpenRight, + true + )) && + (this->checkAgainstUpperBound( + anInterval.lowerBound_, + anInterval.type_ == Interval::Type::Open || anInterval.type_ == Interval::Type::HalfOpenLeft, + true + ) || + this->checkAgainstUpperBound( + anInterval.upperBound_, + anInterval.type_ == Interval::Type::Open || anInterval.type_ == Interval::Type::HalfOpenRight, + false + )) + ); } template @@ -98,42 +123,32 @@ bool Interval::contains(const T& aValue) const throw ostk::core::error::runtime::Undefined("Interval"); } - switch (type_) - { - case Interval::Type::Closed: - return (lowerBound_ <= aValue) && (aValue <= upperBound_); - - case Interval::Type::Open: - return (lowerBound_ < aValue) && (aValue < upperBound_); - - case Interval::Type::HalfOpenLeft: - return (lowerBound_ < aValue) && (aValue <= upperBound_); - - case Interval::Type::HalfOpenRight: - return (lowerBound_ <= aValue) && (aValue < upperBound_); - - default: - throw ostk::core::error::runtime::Wrong("Type"); - break; - } - - return false; + return this->contains(aValue, false); } template bool Interval::contains(const Interval& anInterval) const { - if (!anInterval.isDefined()) + if (!this->isDefined()) { throw ostk::core::error::runtime::Undefined("Interval"); } - if (!this->isDefined()) + if (!anInterval.isDefined()) { throw ostk::core::error::runtime::Undefined("Interval"); } - return this->contains(anInterval.lowerBound_) && this->contains(anInterval.upperBound_); + return this->checkAgainstLowerBound( + anInterval.lowerBound_, + anInterval.type_ == Interval::Type::Open || anInterval.type_ == Interval::Type::HalfOpenLeft, + false + ) && + this->checkAgainstUpperBound( + anInterval.upperBound_, + anInterval.type_ == Interval::Type::Open || anInterval.type_ == Interval::Type::HalfOpenRight, + false + ); } template @@ -500,6 +515,70 @@ types::String Interval::StringFromType(const Interval::Type& anIntervalType) return types::String::Empty(); } +template +bool Interval::contains(const T& aValue, const bool& isOpen) const +{ + return this->checkAgainstLowerBound(aValue, isOpen, false) && this->checkAgainstUpperBound(aValue, isOpen, false); +} + +template +bool Interval::checkAgainstLowerBound(const T& aValue, const bool& isOpen, const bool& isUpperBound) const +{ + switch (type_) + { + case Interval::Type::Closed: + case Interval::Type::HalfOpenRight: + if (isOpen && isUpperBound) + { + return lowerBound_ < aValue; + } + + return lowerBound_ <= aValue; + + case Interval::Type::HalfOpenLeft: + case Interval::Type::Open: + if (isOpen && !isUpperBound) + { + return lowerBound_ <= aValue; + } + + return lowerBound_ < aValue; + + default: + throw ostk::core::error::runtime::Wrong("Type"); + break; + } +} + +template +bool Interval::checkAgainstUpperBound(const T& aValue, const bool& isOpen, const bool& isLowerBound) const +{ + switch (type_) + { + case Interval::Type::Closed: + case Interval::Type::HalfOpenLeft: + if (isOpen && isLowerBound) + { + return upperBound_ > aValue; + } + + return upperBound_ >= aValue; + + case Interval::Type::HalfOpenRight: + case Interval::Type::Open: + if (isOpen && !isLowerBound) + { + return upperBound_ >= aValue; + } + + return upperBound_ > aValue; + + default: + throw ostk::core::error::runtime::Wrong("Type"); + break; + } +} + } // namespace object } // namespace mathematics } // namespace ostk diff --git a/test/OpenSpaceToolkit/Mathematics/Object/Interval.test.cpp b/test/OpenSpaceToolkit/Mathematics/Object/Interval.test.cpp index 8debf3b0..55115f26 100644 --- a/test/OpenSpaceToolkit/Mathematics/Object/Interval.test.cpp +++ b/test/OpenSpaceToolkit/Mathematics/Object/Interval.test.cpp @@ -8,11 +8,11 @@ #include +using ostk::core::type::Real; +using ostk::mathematics::object::Interval; + TEST(OpenSpaceToolkit_Mathematics_Object_Interval, Constructor) { - using ostk::core::type::Real; - using ostk::mathematics::object::Interval; - { Real lowerBound = 0.0; Real upperBound = 1.0; @@ -33,9 +33,6 @@ TEST(OpenSpaceToolkit_Mathematics_Object_Interval, Constructor) TEST(OpenSpaceToolkit_Mathematics_Object_Interval, EqualToOperator) { - using ostk::core::type::Real; - using ostk::mathematics::object::Interval; - { EXPECT_TRUE( Interval(0.0, 1.0, Interval::Type::Closed) == @@ -72,9 +69,6 @@ TEST(OpenSpaceToolkit_Mathematics_Object_Interval, EqualToOperator) TEST(OpenSpaceToolkit_Mathematics_Object_Interval, NotEqualToOperator) { - using ostk::core::type::Real; - using ostk::mathematics::object::Interval; - { EXPECT_FALSE( Interval(0.0, 1.0, Interval::Type::Closed) != @@ -111,9 +105,6 @@ TEST(OpenSpaceToolkit_Mathematics_Object_Interval, NotEqualToOperator) TEST(OpenSpaceToolkit_Mathematics_Object_Interval, IsDefined) { - using ostk::core::type::Real; - using ostk::mathematics::object::Interval; - { EXPECT_TRUE(Interval(0.0, 1.0, Interval::Type::Closed).isDefined()); EXPECT_TRUE(Interval(0.0, 1.0, Interval::Type::Open).isDefined()); @@ -132,9 +123,6 @@ TEST(OpenSpaceToolkit_Mathematics_Object_Interval, IsDefined) TEST(OpenSpaceToolkit_Mathematics_Object_Interval, IsDegenerate) { - using ostk::core::type::Real; - using ostk::mathematics::object::Interval; - { EXPECT_TRUE(Interval(1.0, 1.0, Interval::Type::Closed).isDegenerate()); EXPECT_TRUE(Interval(1.0, 1.0, Interval::Type::Open).isDegenerate()); @@ -157,569 +145,651 @@ TEST(OpenSpaceToolkit_Mathematics_Object_Interval, IsDegenerate) } } -// TEST (OpenSpaceToolkit_Mathematics_Object_Interval, Intersects) -// { +TEST(OpenSpaceToolkit_Mathematics_Object_Interval, Intersects) +{ + { + EXPECT_ANY_THROW(Interval::Undefined().intersects(Interval::Undefined())); + } -// using ostk::core::type::Real ; + { + const Interval interval = Interval::Closed(0.0, 1.0); -// using ostk::mathematics::object::Interval ; + { + EXPECT_ANY_THROW(interval.intersects(Interval::Undefined())); + EXPECT_ANY_THROW(Interval::Undefined().intersects(interval)); + } -// { + { + EXPECT_FALSE(interval.intersects(Interval::Closed(-2.0, -1.0))); + EXPECT_FALSE(interval.intersects(Interval::HalfOpenLeft(-2.0, -1.0))); + EXPECT_FALSE(interval.intersects(Interval::HalfOpenRight(-2.0, -1.0))); + EXPECT_FALSE(interval.intersects(Interval::Open(-2.0, -1.0))); + } -// FAIL() ; + { + EXPECT_TRUE(interval.intersects(Interval::Closed(-1.0, 0.0))); + EXPECT_TRUE(interval.intersects(Interval::HalfOpenLeft(-1.0, 0.0))); + EXPECT_FALSE(interval.intersects(Interval::HalfOpenRight(-1.0, 0.0))); + EXPECT_FALSE(interval.intersects(Interval::Open(-1.0, 0.0))); + } -// } + { + EXPECT_TRUE(interval.intersects(Interval::Closed(-1.0, 0.5))); + EXPECT_TRUE(interval.intersects(Interval::HalfOpenLeft(-1.0, 0.5))); + EXPECT_TRUE(interval.intersects(Interval::HalfOpenRight(-1.0, 0.5))); + EXPECT_TRUE(interval.intersects(Interval::Open(-1.0, 0.5))); + } -// } + { + EXPECT_TRUE(interval.intersects(Interval::Closed(0.25, 0.75))); + EXPECT_TRUE(interval.intersects(Interval::HalfOpenLeft(0.25, 0.75))); + EXPECT_TRUE(interval.intersects(Interval::HalfOpenRight(0.25, 0.75))); + EXPECT_TRUE(interval.intersects(Interval::Open(0.25, 0.75))); + } -// TEST (OpenSpaceToolkit_Mathematics_Object_Interval, Contains) -// { + { + EXPECT_TRUE(interval.intersects(Interval::Closed(0.0, 1.0))); + EXPECT_TRUE(interval.intersects(Interval::HalfOpenLeft(0.0, 1.0))); + EXPECT_TRUE(interval.intersects(Interval::HalfOpenRight(0.0, 1.0))); + EXPECT_TRUE(interval.intersects(Interval::Open(0.0, 1.0))); + } -// using ostk::core::type::Real ; + { + EXPECT_TRUE(interval.intersects(Interval::Closed(-1.0, 2.0))); + EXPECT_TRUE(interval.intersects(Interval::HalfOpenLeft(-1.0, 2.0))); + EXPECT_TRUE(interval.intersects(Interval::HalfOpenRight(-1.0, 2.0))); + EXPECT_TRUE(interval.intersects(Interval::Open(-1.0, 2.0))); + } -// using ostk::mathematics::object::Interval ; + { + EXPECT_TRUE(interval.intersects(Interval::Closed(0.5, 1.5))); + EXPECT_TRUE(interval.intersects(Interval::HalfOpenLeft(0.5, 1.5))); + EXPECT_TRUE(interval.intersects(Interval::HalfOpenRight(0.5, 1.5))); + EXPECT_TRUE(interval.intersects(Interval::Open(0.0, 1.5))); + } -// { + { + EXPECT_TRUE(interval.intersects(Interval::Closed(1.0, 2.0))); + EXPECT_FALSE(interval.intersects(Interval::HalfOpenLeft(1.0, 2.0))); + EXPECT_TRUE(interval.intersects(Interval::HalfOpenRight(1.0, 2.0))); + EXPECT_FALSE(interval.intersects(Interval::Open(1.0, 2.0))); + } -// EXPECT_TRUE(Interval(0.0, 1.0, Interval::Type::Closed).contains(0.0)) ; -// EXPECT_TRUE(Interval(0.0, 1.0, Interval::Type::Closed).contains(0.1)) ; -// EXPECT_TRUE(Interval(0.0, 1.0, Interval::Type::Closed).contains(0.5)) ; -// EXPECT_TRUE(Interval(0.0, 1.0, Interval::Type::Closed).contains(0.9)) ; -// EXPECT_TRUE(Interval(0.0, 1.0, Interval::Type::Closed).contains(1.0)) ; + { + EXPECT_FALSE(interval.intersects(Interval::Closed(2.0, 3.0))); + EXPECT_FALSE(interval.intersects(Interval::HalfOpenLeft(2.0, 3.0))); + EXPECT_FALSE(interval.intersects(Interval::HalfOpenRight(2.0, 3.0))); + EXPECT_FALSE(interval.intersects(Interval::Open(2.0, 3.0))); + } + } -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Closed).contains(-1.0)) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Closed).contains(-0.1)) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Closed).contains(+1.1)) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Closed).contains(+2.0)) ; + { + const Interval interval = Interval::HalfOpenLeft(0.0, 1.0); -// } + { + EXPECT_ANY_THROW(interval.intersects(Interval::Undefined())); + EXPECT_ANY_THROW(Interval::Undefined().intersects(interval)); + } -// { + { + EXPECT_FALSE(interval.intersects(Interval::Closed(-2.0, -1.0))); + EXPECT_FALSE(interval.intersects(Interval::HalfOpenLeft(-2.0, -1.0))); + EXPECT_FALSE(interval.intersects(Interval::HalfOpenRight(-2.0, -1.0))); + EXPECT_FALSE(interval.intersects(Interval::Open(-2.0, -1.0))); + } -// EXPECT_TRUE(Interval(0.0, 1.0, Interval::Type::Open).contains(0.1)) ; -// EXPECT_TRUE(Interval(0.0, 1.0, Interval::Type::Open).contains(0.5)) ; -// EXPECT_TRUE(Interval(0.0, 1.0, Interval::Type::Open).contains(0.9)) ; + { + EXPECT_FALSE(interval.intersects(Interval::Closed(-1.0, 0.0))); + EXPECT_FALSE(interval.intersects(Interval::HalfOpenLeft(-1.0, 0.0))); + EXPECT_FALSE(interval.intersects(Interval::HalfOpenRight(-1.0, 0.0))); + EXPECT_FALSE(interval.intersects(Interval::Open(-1.0, 0.0))); + } -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Open).contains(-1.0)) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Open).contains(-0.1)) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Open).contains(0.0)) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Open).contains(1.0)) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Open).contains(+1.1)) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Open).contains(+2.0)) ; + { + EXPECT_TRUE(interval.intersects(Interval::Closed(-1.0, 0.5))); + EXPECT_TRUE(interval.intersects(Interval::HalfOpenLeft(-1.0, 0.5))); + EXPECT_TRUE(interval.intersects(Interval::HalfOpenRight(-1.0, 0.5))); + EXPECT_TRUE(interval.intersects(Interval::Open(-1.0, 0.5))); + } -// } + { + EXPECT_TRUE(interval.intersects(Interval::Closed(0.25, 0.75))); + EXPECT_TRUE(interval.intersects(Interval::HalfOpenLeft(0.25, 0.75))); + EXPECT_TRUE(interval.intersects(Interval::HalfOpenRight(0.25, 0.75))); + EXPECT_TRUE(interval.intersects(Interval::Open(0.25, 0.75))); + } -// { + { + EXPECT_TRUE(interval.intersects(Interval::Closed(0.0, 1.0))); + EXPECT_TRUE(interval.intersects(Interval::HalfOpenLeft(0.0, 1.0))); + EXPECT_TRUE(interval.intersects(Interval::HalfOpenRight(0.0, 1.0))); + EXPECT_TRUE(interval.intersects(Interval::Open(0.0, 1.0))); + } -// EXPECT_TRUE(Interval(0.0, 1.0, Interval::Type::HalfOpenLeft).contains(0.1)) ; -// EXPECT_TRUE(Interval(0.0, 1.0, Interval::Type::HalfOpenLeft).contains(0.5)) ; -// EXPECT_TRUE(Interval(0.0, 1.0, Interval::Type::HalfOpenLeft).contains(0.9)) ; -// EXPECT_TRUE(Interval(0.0, 1.0, Interval::Type::HalfOpenLeft).contains(1.0)) ; + { + EXPECT_TRUE(interval.intersects(Interval::Closed(-1.0, 2.0))); + EXPECT_TRUE(interval.intersects(Interval::HalfOpenLeft(-1.0, 2.0))); + EXPECT_TRUE(interval.intersects(Interval::HalfOpenRight(-1.0, 2.0))); + EXPECT_TRUE(interval.intersects(Interval::Open(-1.0, 2.0))); + } -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::HalfOpenLeft).contains(-1.0)) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::HalfOpenLeft).contains(-0.1)) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::HalfOpenLeft).contains(0.0)) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::HalfOpenLeft).contains(+1.1)) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::HalfOpenLeft).contains(+2.0)) ; + { + EXPECT_TRUE(interval.intersects(Interval::Closed(0.5, 1.5))); + EXPECT_TRUE(interval.intersects(Interval::HalfOpenLeft(0.5, 1.5))); + EXPECT_TRUE(interval.intersects(Interval::HalfOpenRight(0.5, 1.5))); + EXPECT_TRUE(interval.intersects(Interval::Open(0.0, 1.5))); + } -// } + { + EXPECT_TRUE(interval.intersects(Interval::Closed(1.0, 2.0))); + EXPECT_FALSE(interval.intersects(Interval::HalfOpenLeft(1.0, 2.0))); + EXPECT_TRUE(interval.intersects(Interval::HalfOpenRight(1.0, 2.0))); + EXPECT_FALSE(interval.intersects(Interval::Open(1.0, 2.0))); + } -// { + { + EXPECT_FALSE(interval.intersects(Interval::Closed(2.0, 3.0))); + EXPECT_FALSE(interval.intersects(Interval::HalfOpenLeft(2.0, 3.0))); + EXPECT_FALSE(interval.intersects(Interval::HalfOpenRight(2.0, 3.0))); + EXPECT_FALSE(interval.intersects(Interval::Open(2.0, 3.0))); + } + } -// EXPECT_TRUE(Interval(0.0, 1.0, Interval::Type::HalfOpenRight).contains(0.0)) ; -// EXPECT_TRUE(Interval(0.0, 1.0, Interval::Type::HalfOpenRight).contains(0.1)) ; -// EXPECT_TRUE(Interval(0.0, 1.0, Interval::Type::HalfOpenRight).contains(0.5)) ; -// EXPECT_TRUE(Interval(0.0, 1.0, Interval::Type::HalfOpenRight).contains(0.9)) ; + { + const Interval interval = Interval::HalfOpenRight(0.0, 1.0); -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::HalfOpenRight).contains(-1.0)) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::HalfOpenRight).contains(-0.1)) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::HalfOpenRight).contains(1.0)) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::HalfOpenRight).contains(+1.1)) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::HalfOpenRight).contains(+2.0)) ; + { + EXPECT_ANY_THROW(interval.intersects(Interval::Undefined())); + EXPECT_ANY_THROW(Interval::Undefined().intersects(interval)); + } -// } + { + EXPECT_FALSE(interval.intersects(Interval::Closed(-2.0, -1.0))); + EXPECT_FALSE(interval.intersects(Interval::HalfOpenLeft(-2.0, -1.0))); + EXPECT_FALSE(interval.intersects(Interval::HalfOpenRight(-2.0, -1.0))); + EXPECT_FALSE(interval.intersects(Interval::Open(-2.0, -1.0))); + } -// { + { + EXPECT_TRUE(interval.intersects(Interval::Closed(-1.0, 0.0))); + EXPECT_TRUE(interval.intersects(Interval::HalfOpenLeft(-1.0, 0.0))); + EXPECT_FALSE(interval.intersects(Interval::HalfOpenRight(-1.0, 0.0))); + EXPECT_FALSE(interval.intersects(Interval::Open(-1.0, 0.0))); + } -// EXPECT_ANY_THROW(Interval::Undefined().contains(1.0)) ; -// EXPECT_ANY_THROW(Interval::Undefined().contains(Real::Undefined())) ; + { + EXPECT_TRUE(interval.intersects(Interval::Closed(-1.0, 0.5))); + EXPECT_TRUE(interval.intersects(Interval::HalfOpenLeft(-1.0, 0.5))); + EXPECT_TRUE(interval.intersects(Interval::HalfOpenRight(-1.0, 0.5))); + EXPECT_TRUE(interval.intersects(Interval::Open(-1.0, 0.5))); + } -// EXPECT_ANY_THROW(Interval(0.0, 1.0, Interval::Type::Closed).contains(Real::Undefined())) ; -// EXPECT_ANY_THROW(Interval(0.0, 1.0, Interval::Type::Open).contains(Real::Undefined())) ; -// EXPECT_ANY_THROW(Interval(0.0, 1.0, Interval::Type::HalfOpenLeft).contains(Real::Undefined())) ; -// EXPECT_ANY_THROW(Interval(0.0, 1.0, Interval::Type::HalfOpenRight).contains(Real::Undefined())) ; + { + EXPECT_TRUE(interval.intersects(Interval::Closed(0.25, 0.75))); + EXPECT_TRUE(interval.intersects(Interval::HalfOpenLeft(0.25, 0.75))); + EXPECT_TRUE(interval.intersects(Interval::HalfOpenRight(0.25, 0.75))); + EXPECT_TRUE(interval.intersects(Interval::Open(0.25, 0.75))); + } -// } + { + EXPECT_TRUE(interval.intersects(Interval::Closed(0.0, 1.0))); + EXPECT_TRUE(interval.intersects(Interval::HalfOpenLeft(0.0, 1.0))); + EXPECT_TRUE(interval.intersects(Interval::HalfOpenRight(0.0, 1.0))); + EXPECT_TRUE(interval.intersects(Interval::Open(0.0, 1.0))); + } -// // Interval(Closed)::contains(Interval) + { + EXPECT_TRUE(interval.intersects(Interval::Closed(-1.0, 2.0))); + EXPECT_TRUE(interval.intersects(Interval::HalfOpenLeft(-1.0, 2.0))); + EXPECT_TRUE(interval.intersects(Interval::HalfOpenRight(-1.0, 2.0))); + EXPECT_TRUE(interval.intersects(Interval::Open(-1.0, 2.0))); + } -// { + { + EXPECT_TRUE(interval.intersects(Interval::Closed(0.5, 1.5))); + EXPECT_TRUE(interval.intersects(Interval::HalfOpenLeft(0.5, 1.5))); + EXPECT_TRUE(interval.intersects(Interval::HalfOpenRight(0.5, 1.5))); + EXPECT_TRUE(interval.intersects(Interval::Open(0.0, 1.5))); + } + + { + EXPECT_FALSE(interval.intersects(Interval::Closed(1.0, 2.0))); + EXPECT_FALSE(interval.intersects(Interval::HalfOpenLeft(1.0, 2.0))); + EXPECT_FALSE(interval.intersects(Interval::HalfOpenRight(1.0, 2.0))); + EXPECT_FALSE(interval.intersects(Interval::Open(1.0, 2.0))); + } -// // Closed - -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Closed).contains(Interval(-1.0, -1.0, -// Interval::Type::Closed))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Closed).contains(Interval(-1.0, -0.5, Interval::Type::Closed))) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Closed).contains(Interval(-1.0, +0.0, -// Interval::Type::Closed))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Closed).contains(Interval(-1.0, +0.5, Interval::Type::Closed))) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Closed).contains(Interval(-1.0, +1.0, -// Interval::Type::Closed))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Closed).contains(Interval(-1.0, +1.5, Interval::Type::Closed))) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Closed).contains(Interval(-1.0, +2.0, -// Interval::Type::Closed))) ; - -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Closed).contains(Interval(-0.5, -0.5, -// Interval::Type::Closed))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Closed).contains(Interval(-0.5, +0.0, Interval::Type::Closed))) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Closed).contains(Interval(-0.5, +0.5, -// Interval::Type::Closed))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Closed).contains(Interval(-0.5, +1.0, Interval::Type::Closed))) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Closed).contains(Interval(-0.5, +1.5, -// Interval::Type::Closed))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Closed).contains(Interval(-0.5, +2.0, Interval::Type::Closed))) ; - -// EXPECT_TRUE (Interval(0.0, 1.0, Interval::Type::Closed).contains(Interval(+0.0, +0.0, -// Interval::Type::Closed))) ; EXPECT_TRUE (Interval(0.0, 1.0, -// Interval::Type::Closed).contains(Interval(+0.0, +0.5, Interval::Type::Closed))) ; -// EXPECT_TRUE (Interval(0.0, 1.0, Interval::Type::Closed).contains(Interval(+0.0, +1.0, -// Interval::Type::Closed))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Closed).contains(Interval(+0.0, +1.5, Interval::Type::Closed))) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Closed).contains(Interval(+0.0, +2.0, -// Interval::Type::Closed))) ; - -// EXPECT_TRUE (Interval(0.0, 1.0, Interval::Type::Closed).contains(Interval(+0.5, +0.5, -// Interval::Type::Closed))) ; EXPECT_TRUE (Interval(0.0, 1.0, -// Interval::Type::Closed).contains(Interval(+0.5, +1.0, Interval::Type::Closed))) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Closed).contains(Interval(+0.5, +1.5, -// Interval::Type::Closed))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Closed).contains(Interval(+0.5, +2.0, Interval::Type::Closed))) ; - -// EXPECT_TRUE (Interval(0.0, 1.0, Interval::Type::Closed).contains(Interval(+1.0, +1.0, -// Interval::Type::Closed))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Closed).contains(Interval(+1.0, +1.5, Interval::Type::Closed))) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Closed).contains(Interval(+1.0, +2.0, -// Interval::Type::Closed))) ; - -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Closed).contains(Interval(+1.5, +1.5, -// Interval::Type::Closed))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Closed).contains(Interval(+1.5, +2.0, Interval::Type::Closed))) ; - -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Closed).contains(Interval(+2.0, +2.0, -// Interval::Type::Closed))) ; - -// // Open - -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Closed).contains(Interval(-1.0, -1.0, -// Interval::Type::Open))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Closed).contains(Interval(-1.0, -0.5, Interval::Type::Open))) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Closed).contains(Interval(-1.0, +0.0, -// Interval::Type::Open))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Closed).contains(Interval(-1.0, +0.5, Interval::Type::Open))) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Closed).contains(Interval(-1.0, +1.0, -// Interval::Type::Open))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Closed).contains(Interval(-1.0, +1.5, Interval::Type::Open))) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Closed).contains(Interval(-1.0, +2.0, -// Interval::Type::Open))) ; - -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Closed).contains(Interval(-0.5, -0.5, -// Interval::Type::Open))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Closed).contains(Interval(-0.5, +0.0, Interval::Type::Open))) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Closed).contains(Interval(-0.5, +0.5, -// Interval::Type::Open))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Closed).contains(Interval(-0.5, +1.0, Interval::Type::Open))) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Closed).contains(Interval(-0.5, +1.5, -// Interval::Type::Open))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Closed).contains(Interval(-0.5, +2.0, Interval::Type::Open))) ; - -// EXPECT_TRUE (Interval(0.0, 1.0, Interval::Type::Closed).contains(Interval(+0.0, +0.0, -// Interval::Type::Open))) ; EXPECT_TRUE (Interval(0.0, 1.0, -// Interval::Type::Closed).contains(Interval(+0.0, +0.5, Interval::Type::Open))) ; EXPECT_TRUE -// (Interval(0.0, 1.0, Interval::Type::Closed).contains(Interval(+0.0, +1.0, -// Interval::Type::Open))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Closed).contains(Interval(+0.0, +1.5, Interval::Type::Open))) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Closed).contains(Interval(+0.0, +2.0, -// Interval::Type::Open))) ; - -// EXPECT_TRUE (Interval(0.0, 1.0, Interval::Type::Closed).contains(Interval(+0.5, +0.5, -// Interval::Type::Open))) ; EXPECT_TRUE (Interval(0.0, 1.0, -// Interval::Type::Closed).contains(Interval(+0.5, +1.0, Interval::Type::Open))) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Closed).contains(Interval(+0.5, +1.5, -// Interval::Type::Open))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Closed).contains(Interval(+0.5, +2.0, Interval::Type::Open))) ; - -// EXPECT_TRUE (Interval(0.0, 1.0, Interval::Type::Closed).contains(Interval(+1.0, +1.0, -// Interval::Type::Open))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Closed).contains(Interval(+1.0, +1.5, Interval::Type::Open))) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Closed).contains(Interval(+1.0, +2.0, -// Interval::Type::Open))) ; - -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Closed).contains(Interval(+1.5, +1.5, -// Interval::Type::Open))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Closed).contains(Interval(+1.5, +2.0, Interval::Type::Open))) ; - -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Closed).contains(Interval(+2.0, +2.0, -// Interval::Type::Open))) ; - -// // HalfOpenLeft - -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Closed).contains(Interval(-1.0, -1.0, -// Interval::Type::HalfOpenLeft))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Closed).contains(Interval(-1.0, -0.5, Interval::Type::HalfOpenLeft))) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Closed).contains(Interval(-1.0, +0.0, -// Interval::Type::HalfOpenLeft))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Closed).contains(Interval(-1.0, +0.5, Interval::Type::HalfOpenLeft))) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Closed).contains(Interval(-1.0, +1.0, -// Interval::Type::HalfOpenLeft))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Closed).contains(Interval(-1.0, +1.5, Interval::Type::HalfOpenLeft))) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Closed).contains(Interval(-1.0, +2.0, -// Interval::Type::HalfOpenLeft))) ; - -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Closed).contains(Interval(-0.5, -0.5, -// Interval::Type::HalfOpenLeft))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Closed).contains(Interval(-0.5, +0.0, Interval::Type::HalfOpenLeft))) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Closed).contains(Interval(-0.5, +0.5, -// Interval::Type::HalfOpenLeft))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Closed).contains(Interval(-0.5, +1.0, Interval::Type::HalfOpenLeft))) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Closed).contains(Interval(-0.5, +1.5, -// Interval::Type::HalfOpenLeft))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Closed).contains(Interval(-0.5, +2.0, Interval::Type::HalfOpenLeft))) ; - -// EXPECT_TRUE (Interval(0.0, 1.0, Interval::Type::Closed).contains(Interval(+0.0, +0.0, -// Interval::Type::HalfOpenLeft))) ; EXPECT_TRUE (Interval(0.0, 1.0, -// Interval::Type::Closed).contains(Interval(+0.0, +0.5, Interval::Type::HalfOpenLeft))) ; -// EXPECT_TRUE (Interval(0.0, 1.0, Interval::Type::Closed).contains(Interval(+0.0, +1.0, -// Interval::Type::HalfOpenLeft))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Closed).contains(Interval(+0.0, +1.5, Interval::Type::HalfOpenLeft))) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Closed).contains(Interval(+0.0, +2.0, -// Interval::Type::HalfOpenLeft))) ; - -// EXPECT_TRUE (Interval(0.0, 1.0, Interval::Type::Closed).contains(Interval(+0.5, +0.5, -// Interval::Type::HalfOpenLeft))) ; EXPECT_TRUE (Interval(0.0, 1.0, -// Interval::Type::Closed).contains(Interval(+0.5, +1.0, Interval::Type::HalfOpenLeft))) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Closed).contains(Interval(+0.5, +1.5, -// Interval::Type::HalfOpenLeft))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Closed).contains(Interval(+0.5, +2.0, Interval::Type::HalfOpenLeft))) ; - -// EXPECT_TRUE (Interval(0.0, 1.0, Interval::Type::Closed).contains(Interval(+1.0, +1.0, -// Interval::Type::HalfOpenLeft))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Closed).contains(Interval(+1.0, +1.5, Interval::Type::HalfOpenLeft))) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Closed).contains(Interval(+1.0, +2.0, -// Interval::Type::HalfOpenLeft))) ; - -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Closed).contains(Interval(+1.5, +1.5, -// Interval::Type::HalfOpenLeft))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Closed).contains(Interval(+1.5, +2.0, Interval::Type::HalfOpenLeft))) ; - -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Closed).contains(Interval(+2.0, +2.0, -// Interval::Type::HalfOpenLeft))) ; - -// // HalfOpenRight - -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Closed).contains(Interval(-1.0, -1.0, -// Interval::Type::HalfOpenRight))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Closed).contains(Interval(-1.0, -0.5, Interval::Type::HalfOpenRight))) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Closed).contains(Interval(-1.0, +0.0, -// Interval::Type::HalfOpenRight))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Closed).contains(Interval(-1.0, +0.5, Interval::Type::HalfOpenRight))) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Closed).contains(Interval(-1.0, +1.0, -// Interval::Type::HalfOpenRight))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Closed).contains(Interval(-1.0, +1.5, Interval::Type::HalfOpenRight))) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Closed).contains(Interval(-1.0, +2.0, -// Interval::Type::HalfOpenRight))) ; - -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Closed).contains(Interval(-0.5, -0.5, -// Interval::Type::HalfOpenRight))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Closed).contains(Interval(-0.5, +0.0, Interval::Type::HalfOpenRight))) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Closed).contains(Interval(-0.5, +0.5, -// Interval::Type::HalfOpenRight))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Closed).contains(Interval(-0.5, +1.0, Interval::Type::HalfOpenRight))) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Closed).contains(Interval(-0.5, +1.5, -// Interval::Type::HalfOpenRight))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Closed).contains(Interval(-0.5, +2.0, Interval::Type::HalfOpenRight))) ; - -// EXPECT_TRUE (Interval(0.0, 1.0, Interval::Type::Closed).contains(Interval(+0.0, +0.0, -// Interval::Type::HalfOpenRight))) ; EXPECT_TRUE (Interval(0.0, 1.0, -// Interval::Type::Closed).contains(Interval(+0.0, +0.5, Interval::Type::HalfOpenRight))) ; -// EXPECT_TRUE (Interval(0.0, 1.0, Interval::Type::Closed).contains(Interval(+0.0, +1.0, -// Interval::Type::HalfOpenRight))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Closed).contains(Interval(+0.0, +1.5, Interval::Type::HalfOpenRight))) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Closed).contains(Interval(+0.0, +2.0, -// Interval::Type::HalfOpenRight))) ; - -// EXPECT_TRUE (Interval(0.0, 1.0, Interval::Type::Closed).contains(Interval(+0.5, +0.5, -// Interval::Type::HalfOpenRight))) ; EXPECT_TRUE (Interval(0.0, 1.0, -// Interval::Type::Closed).contains(Interval(+0.5, +1.0, Interval::Type::HalfOpenRight))) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Closed).contains(Interval(+0.5, +1.5, -// Interval::Type::HalfOpenRight))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Closed).contains(Interval(+0.5, +2.0, Interval::Type::HalfOpenRight))) ; - -// EXPECT_TRUE (Interval(0.0, 1.0, Interval::Type::Closed).contains(Interval(+1.0, +1.0, -// Interval::Type::HalfOpenRight))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Closed).contains(Interval(+1.0, +1.5, Interval::Type::HalfOpenRight))) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Closed).contains(Interval(+1.0, +2.0, -// Interval::Type::HalfOpenRight))) ; - -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Closed).contains(Interval(+1.5, +1.5, -// Interval::Type::HalfOpenRight))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Closed).contains(Interval(+1.5, +2.0, Interval::Type::HalfOpenRight))) ; - -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Closed).contains(Interval(+2.0, +2.0, -// Interval::Type::HalfOpenRight))) ; + { + EXPECT_FALSE(interval.intersects(Interval::Closed(2.0, 3.0))); + EXPECT_FALSE(interval.intersects(Interval::HalfOpenLeft(2.0, 3.0))); + EXPECT_FALSE(interval.intersects(Interval::HalfOpenRight(2.0, 3.0))); + EXPECT_FALSE(interval.intersects(Interval::Open(2.0, 3.0))); + } + } -// } + { + const Interval interval = Interval::Open(0.0, 1.0); -// // Interval(Open)::contains(Interval) + { + EXPECT_ANY_THROW(interval.intersects(Interval::Undefined())); + EXPECT_ANY_THROW(Interval::Undefined().intersects(interval)); + } -// { + { + EXPECT_FALSE(interval.intersects(Interval::Closed(-2.0, -1.0))); + EXPECT_FALSE(interval.intersects(Interval::HalfOpenLeft(-2.0, -1.0))); + EXPECT_FALSE(interval.intersects(Interval::HalfOpenRight(-2.0, -1.0))); + EXPECT_FALSE(interval.intersects(Interval::Open(-2.0, -1.0))); + } -// // Closed - -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Open).contains(Interval(-1.0, -1.0, -// Interval::Type::Closed))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Open).contains(Interval(-1.0, -0.5, Interval::Type::Closed))) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Open).contains(Interval(-1.0, +0.0, -// Interval::Type::Closed))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Open).contains(Interval(-1.0, +0.5, Interval::Type::Closed))) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Open).contains(Interval(-1.0, +1.0, -// Interval::Type::Closed))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Open).contains(Interval(-1.0, +1.5, Interval::Type::Closed))) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Open).contains(Interval(-1.0, +2.0, -// Interval::Type::Closed))) ; - -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Open).contains(Interval(-0.5, -0.5, -// Interval::Type::Closed))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Open).contains(Interval(-0.5, +0.0, Interval::Type::Closed))) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Open).contains(Interval(-0.5, +0.5, -// Interval::Type::Closed))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Open).contains(Interval(-0.5, +1.0, Interval::Type::Closed))) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Open).contains(Interval(-0.5, +1.5, -// Interval::Type::Closed))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Open).contains(Interval(-0.5, +2.0, Interval::Type::Closed))) ; - -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Open).contains(Interval(+0.0, +0.0, -// Interval::Type::Closed))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Open).contains(Interval(+0.0, +0.5, Interval::Type::Closed))) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Open).contains(Interval(+0.0, +1.0, -// Interval::Type::Closed))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Open).contains(Interval(+0.0, +1.5, Interval::Type::Closed))) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Open).contains(Interval(+0.0, +2.0, -// Interval::Type::Closed))) ; - -// EXPECT_TRUE (Interval(0.0, 1.0, Interval::Type::Open).contains(Interval(+0.5, +0.5, -// Interval::Type::Closed))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Open).contains(Interval(+0.5, +1.0, Interval::Type::Closed))) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Open).contains(Interval(+0.5, +1.5, -// Interval::Type::Closed))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Open).contains(Interval(+0.5, +2.0, Interval::Type::Closed))) ; - -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Open).contains(Interval(+1.0, +1.0, -// Interval::Type::Closed))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Open).contains(Interval(+1.0, +1.5, Interval::Type::Closed))) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Open).contains(Interval(+1.0, +2.0, -// Interval::Type::Closed))) ; - -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Open).contains(Interval(+1.5, +1.5, -// Interval::Type::Closed))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Open).contains(Interval(+1.5, +2.0, Interval::Type::Closed))) ; - -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Open).contains(Interval(+2.0, +2.0, -// Interval::Type::Closed))) ; - -// // Open - -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Open).contains(Interval(-1.0, -1.0, -// Interval::Type::Open))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Open).contains(Interval(-1.0, -0.5, Interval::Type::Open))) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Open).contains(Interval(-1.0, +0.0, -// Interval::Type::Open))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Open).contains(Interval(-1.0, +0.5, Interval::Type::Open))) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Open).contains(Interval(-1.0, +1.0, -// Interval::Type::Open))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Open).contains(Interval(-1.0, +1.5, Interval::Type::Open))) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Open).contains(Interval(-1.0, +2.0, -// Interval::Type::Open))) ; - -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Open).contains(Interval(-0.5, -0.5, -// Interval::Type::Open))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Open).contains(Interval(-0.5, +0.0, Interval::Type::Open))) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Open).contains(Interval(-0.5, +0.5, -// Interval::Type::Open))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Open).contains(Interval(-0.5, +1.0, Interval::Type::Open))) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Open).contains(Interval(-0.5, +1.5, -// Interval::Type::Open))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Open).contains(Interval(-0.5, +2.0, Interval::Type::Open))) ; - -// EXPECT_TRUE (Interval(0.0, 1.0, Interval::Type::Open).contains(Interval(+0.0, +0.0, -// Interval::Type::Open))) ; EXPECT_TRUE (Interval(0.0, 1.0, -// Interval::Type::Open).contains(Interval(+0.0, +0.5, Interval::Type::Open))) ; EXPECT_TRUE -// (Interval(0.0, 1.0, Interval::Type::Open).contains(Interval(+0.0, +1.0, -// Interval::Type::Open))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Open).contains(Interval(+0.0, +1.5, Interval::Type::Open))) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Open).contains(Interval(+0.0, +2.0, -// Interval::Type::Open))) ; - -// EXPECT_TRUE (Interval(0.0, 1.0, Interval::Type::Open).contains(Interval(+0.5, +0.5, -// Interval::Type::Open))) ; EXPECT_TRUE (Interval(0.0, 1.0, -// Interval::Type::Open).contains(Interval(+0.5, +1.0, Interval::Type::Open))) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Open).contains(Interval(+0.5, +1.5, -// Interval::Type::Open))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Open).contains(Interval(+0.5, +2.0, Interval::Type::Open))) ; - -// EXPECT_TRUE (Interval(0.0, 1.0, Interval::Type::Open).contains(Interval(+1.0, +1.0, -// Interval::Type::Open))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Open).contains(Interval(+1.0, +1.5, Interval::Type::Open))) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Open).contains(Interval(+1.0, +2.0, -// Interval::Type::Open))) ; - -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Open).contains(Interval(+1.5, +1.5, -// Interval::Type::Open))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Open).contains(Interval(+1.5, +2.0, Interval::Type::Open))) ; - -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Open).contains(Interval(+2.0, +2.0, -// Interval::Type::Open))) ; - -// // HalfOpenLeft - -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Open).contains(Interval(-1.0, -1.0, -// Interval::Type::HalfOpenLeft))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Open).contains(Interval(-1.0, -0.5, Interval::Type::HalfOpenLeft))) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Open).contains(Interval(-1.0, +0.0, -// Interval::Type::HalfOpenLeft))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Open).contains(Interval(-1.0, +0.5, Interval::Type::HalfOpenLeft))) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Open).contains(Interval(-1.0, +1.0, -// Interval::Type::HalfOpenLeft))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Open).contains(Interval(-1.0, +1.5, Interval::Type::HalfOpenLeft))) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Open).contains(Interval(-1.0, +2.0, -// Interval::Type::HalfOpenLeft))) ; - -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Open).contains(Interval(-0.5, -0.5, -// Interval::Type::HalfOpenLeft))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Open).contains(Interval(-0.5, +0.0, Interval::Type::HalfOpenLeft))) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Open).contains(Interval(-0.5, +0.5, -// Interval::Type::HalfOpenLeft))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Open).contains(Interval(-0.5, +1.0, Interval::Type::HalfOpenLeft))) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Open).contains(Interval(-0.5, +1.5, -// Interval::Type::HalfOpenLeft))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Open).contains(Interval(-0.5, +2.0, Interval::Type::HalfOpenLeft))) ; - -// EXPECT_TRUE (Interval(0.0, 1.0, Interval::Type::Open).contains(Interval(+0.0, +0.0, -// Interval::Type::HalfOpenLeft))) ; EXPECT_TRUE (Interval(0.0, 1.0, -// Interval::Type::Open).contains(Interval(+0.0, +0.5, Interval::Type::HalfOpenLeft))) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Open).contains(Interval(+0.0, +1.0, -// Interval::Type::HalfOpenLeft))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Open).contains(Interval(+0.0, +1.5, Interval::Type::HalfOpenLeft))) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Open).contains(Interval(+0.0, +2.0, -// Interval::Type::HalfOpenLeft))) ; - -// EXPECT_TRUE (Interval(0.0, 1.0, Interval::Type::Open).contains(Interval(+0.5, +0.5, -// Interval::Type::HalfOpenLeft))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Open).contains(Interval(+0.5, +1.0, Interval::Type::HalfOpenLeft))) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Open).contains(Interval(+0.5, +1.5, -// Interval::Type::HalfOpenLeft))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Open).contains(Interval(+0.5, +2.0, Interval::Type::HalfOpenLeft))) ; - -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Open).contains(Interval(+1.0, +1.0, -// Interval::Type::HalfOpenLeft))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Open).contains(Interval(+1.0, +1.5, Interval::Type::HalfOpenLeft))) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Open).contains(Interval(+1.0, +2.0, -// Interval::Type::HalfOpenLeft))) ; - -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Open).contains(Interval(+1.5, +1.5, -// Interval::Type::HalfOpenLeft))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Open).contains(Interval(+1.5, +2.0, Interval::Type::HalfOpenLeft))) ; - -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Open).contains(Interval(+2.0, +2.0, -// Interval::Type::HalfOpenLeft))) ; - -// // HalfOpenRight - -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Open).contains(Interval(-1.0, -1.0, -// Interval::Type::HalfOpenRight))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Open).contains(Interval(-1.0, -0.5, Interval::Type::HalfOpenRight))) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Open).contains(Interval(-1.0, +0.0, -// Interval::Type::HalfOpenRight))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Open).contains(Interval(-1.0, +0.5, Interval::Type::HalfOpenRight))) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Open).contains(Interval(-1.0, +1.0, -// Interval::Type::HalfOpenRight))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Open).contains(Interval(-1.0, +1.5, Interval::Type::HalfOpenRight))) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Open).contains(Interval(-1.0, +2.0, -// Interval::Type::HalfOpenRight))) ; - -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Open).contains(Interval(-0.5, -0.5, -// Interval::Type::HalfOpenRight))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Open).contains(Interval(-0.5, +0.0, Interval::Type::HalfOpenRight))) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Open).contains(Interval(-0.5, +0.5, -// Interval::Type::HalfOpenRight))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Open).contains(Interval(-0.5, +1.0, Interval::Type::HalfOpenRight))) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Open).contains(Interval(-0.5, +1.5, -// Interval::Type::HalfOpenRight))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Open).contains(Interval(-0.5, +2.0, Interval::Type::HalfOpenRight))) ; - -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Open).contains(Interval(+0.0, +0.0, -// Interval::Type::HalfOpenRight))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Open).contains(Interval(+0.0, +0.5, Interval::Type::HalfOpenRight))) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Open).contains(Interval(+0.0, +1.0, -// Interval::Type::HalfOpenRight))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Open).contains(Interval(+0.0, +1.5, Interval::Type::HalfOpenRight))) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Open).contains(Interval(+0.0, +2.0, -// Interval::Type::HalfOpenRight))) ; - -// EXPECT_TRUE (Interval(0.0, 1.0, Interval::Type::Open).contains(Interval(+0.5, +0.5, -// Interval::Type::HalfOpenRight))) ; EXPECT_TRUE (Interval(0.0, 1.0, -// Interval::Type::Open).contains(Interval(+0.5, +1.0, Interval::Type::HalfOpenRight))) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Open).contains(Interval(+0.5, +1.5, -// Interval::Type::HalfOpenRight))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Open).contains(Interval(+0.5, +2.0, Interval::Type::HalfOpenRight))) ; - -// EXPECT_TRUE (Interval(0.0, 1.0, Interval::Type::Open).contains(Interval(+1.0, +1.0, -// Interval::Type::HalfOpenRight))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Open).contains(Interval(+1.0, +1.5, Interval::Type::HalfOpenRight))) ; -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Open).contains(Interval(+1.0, +2.0, -// Interval::Type::HalfOpenRight))) ; - -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Open).contains(Interval(+1.5, +1.5, -// Interval::Type::HalfOpenRight))) ; EXPECT_FALSE(Interval(0.0, 1.0, -// Interval::Type::Open).contains(Interval(+1.5, +2.0, Interval::Type::HalfOpenRight))) ; - -// EXPECT_FALSE(Interval(0.0, 1.0, Interval::Type::Open).contains(Interval(+2.0, +2.0, -// Interval::Type::HalfOpenRight))) ; + { + EXPECT_FALSE(interval.intersects(Interval::Closed(-1.0, 0.0))); + EXPECT_FALSE(interval.intersects(Interval::HalfOpenLeft(-1.0, 0.0))); + EXPECT_FALSE(interval.intersects(Interval::HalfOpenRight(-1.0, 0.0))); + EXPECT_FALSE(interval.intersects(Interval::Open(-1.0, 0.0))); + } -// } + { + EXPECT_TRUE(interval.intersects(Interval::Closed(-1.0, 0.5))); + EXPECT_TRUE(interval.intersects(Interval::HalfOpenLeft(-1.0, 0.5))); + EXPECT_TRUE(interval.intersects(Interval::HalfOpenRight(-1.0, 0.5))); + EXPECT_TRUE(interval.intersects(Interval::Open(-1.0, 0.5))); + } -// // Interval(HalfOpenLeft)::contains(Interval) + { + EXPECT_TRUE(interval.intersects(Interval::Closed(0.25, 0.75))); + EXPECT_TRUE(interval.intersects(Interval::HalfOpenLeft(0.25, 0.75))); + EXPECT_TRUE(interval.intersects(Interval::HalfOpenRight(0.25, 0.75))); + EXPECT_TRUE(interval.intersects(Interval::Open(0.25, 0.75))); + } -// { + { + EXPECT_TRUE(interval.intersects(Interval::Closed(0.0, 1.0))); + EXPECT_TRUE(interval.intersects(Interval::HalfOpenLeft(0.0, 1.0))); + EXPECT_TRUE(interval.intersects(Interval::HalfOpenRight(0.0, 1.0))); + EXPECT_TRUE(interval.intersects(Interval::Open(0.0, 1.0))); + } -// FAIL() ; + { + EXPECT_TRUE(interval.intersects(Interval::Closed(-1.0, 2.0))); + EXPECT_TRUE(interval.intersects(Interval::HalfOpenLeft(-1.0, 2.0))); + EXPECT_TRUE(interval.intersects(Interval::HalfOpenRight(-1.0, 2.0))); + EXPECT_TRUE(interval.intersects(Interval::Open(-1.0, 2.0))); + } -// } + { + EXPECT_TRUE(interval.intersects(Interval::Closed(0.5, 1.5))); + EXPECT_TRUE(interval.intersects(Interval::HalfOpenLeft(0.5, 1.5))); + EXPECT_TRUE(interval.intersects(Interval::HalfOpenRight(0.5, 1.5))); + EXPECT_TRUE(interval.intersects(Interval::Open(0.0, 1.5))); + } -// // Interval(OpHalfOpenRighten)::contains(Interval) + { + EXPECT_FALSE(interval.intersects(Interval::Closed(1.0, 2.0))); + EXPECT_FALSE(interval.intersects(Interval::HalfOpenLeft(1.0, 2.0))); + EXPECT_FALSE(interval.intersects(Interval::HalfOpenRight(1.0, 2.0))); + EXPECT_FALSE(interval.intersects(Interval::Open(1.0, 2.0))); + } -// { + { + EXPECT_FALSE(interval.intersects(Interval::Closed(2.0, 3.0))); + EXPECT_FALSE(interval.intersects(Interval::HalfOpenLeft(2.0, 3.0))); + EXPECT_FALSE(interval.intersects(Interval::HalfOpenRight(2.0, 3.0))); + EXPECT_FALSE(interval.intersects(Interval::Open(2.0, 3.0))); + } + } +} -// FAIL() ; +TEST(OpenSpaceToolkit_Mathematics_Object_Interval, ContainsValue) +{ + { + EXPECT_ANY_THROW(Interval::Undefined().contains(0.0)); + EXPECT_ANY_THROW(Interval::Undefined().contains(Real::Undefined())); + } -// } + { + const Interval interval = Interval::Closed(0.0, 1.0); -// { + EXPECT_ANY_THROW(interval.contains(Real::Undefined())); -// EXPECT_ANY_THROW(Interval::Undefined().contains(Interval(0.0, 1.0, -// Interval::Type::Closed))) ; -// EXPECT_ANY_THROW(Interval::Undefined().contains(Interval::Undefined())) ; + EXPECT_FALSE(interval.contains(-1.0)); + EXPECT_TRUE(interval.contains(0.0)); + EXPECT_TRUE(interval.contains(0.5)); + EXPECT_TRUE(interval.contains(1.0)); + EXPECT_FALSE(interval.contains(2.0)); + } -// EXPECT_ANY_THROW(Interval(0.0, 1.0, -// Interval::Type::Closed).contains(Interval::Undefined())) ; -// EXPECT_ANY_THROW(Interval(0.0, 1.0, Interval::Type::Open).contains(Interval::Undefined())) -// ; EXPECT_ANY_THROW(Interval(0.0, 1.0, -// Interval::Type::HalfOpenLeft).contains(Interval::Undefined())) ; -// EXPECT_ANY_THROW(Interval(0.0, 1.0, -// Interval::Type::HalfOpenRight).contains(Interval::Undefined())) ; + { + const Interval interval = Interval::HalfOpenLeft(0.0, 1.0); -// } + EXPECT_ANY_THROW(interval.contains(Real::Undefined())); -// } + EXPECT_FALSE(interval.contains(-1.0)); + EXPECT_FALSE(interval.contains(0.0)); + EXPECT_TRUE(interval.contains(0.5)); + EXPECT_TRUE(interval.contains(1.0)); + EXPECT_FALSE(interval.contains(2.0)); + } + + { + const Interval interval = Interval::HalfOpenRight(0.0, 1.0); + + EXPECT_ANY_THROW(interval.contains(Real::Undefined())); + + EXPECT_FALSE(interval.contains(-1.0)); + EXPECT_TRUE(interval.contains(0.0)); + EXPECT_TRUE(interval.contains(0.5)); + EXPECT_FALSE(interval.contains(1.0)); + EXPECT_FALSE(interval.contains(2.0)); + } + + { + const Interval interval = Interval::Open(0.0, 1.0); + + EXPECT_ANY_THROW(interval.contains(Real::Undefined())); + + EXPECT_FALSE(interval.contains(-1.0)); + EXPECT_FALSE(interval.contains(0.0)); + EXPECT_TRUE(interval.contains(0.5)); + EXPECT_FALSE(interval.contains(1.0)); + EXPECT_FALSE(interval.contains(2.0)); + } +} + +TEST(OpenSpaceToolkit_Mathematics_Object_Interval, ContainsInterval) +{ + { + EXPECT_ANY_THROW(Interval::Undefined().contains(Interval::Undefined())); + } + + { + const Interval interval = Interval::Closed(0.0, 1.0); + + { + EXPECT_ANY_THROW(interval.contains(Interval::Undefined())); + EXPECT_ANY_THROW(Interval::Undefined().contains(interval)); + } + + { + EXPECT_FALSE(interval.contains(Interval::Closed(-2.0, -1.0))); + EXPECT_FALSE(interval.contains(Interval::HalfOpenLeft(-2.0, -1.0))); + EXPECT_FALSE(interval.contains(Interval::HalfOpenRight(-2.0, -1.0))); + EXPECT_FALSE(interval.contains(Interval::Open(-2.0, -1.0))); + } + + { + EXPECT_FALSE(interval.contains(Interval::Closed(-1.0, 0.0))); + EXPECT_FALSE(interval.contains(Interval::HalfOpenLeft(-1.0, 0.0))); + EXPECT_FALSE(interval.contains(Interval::HalfOpenRight(-1.0, 0.0))); + EXPECT_FALSE(interval.contains(Interval::Open(-1.0, 0.0))); + } + + { + EXPECT_FALSE(interval.contains(Interval::Closed(-1.0, 0.5))); + EXPECT_FALSE(interval.contains(Interval::HalfOpenLeft(-1.0, 0.5))); + EXPECT_FALSE(interval.contains(Interval::HalfOpenRight(-1.0, 0.5))); + EXPECT_FALSE(interval.contains(Interval::Open(-1.0, 0.5))); + } + + { + EXPECT_TRUE(interval.contains(Interval::Closed(0.25, 0.75))); + EXPECT_TRUE(interval.contains(Interval::HalfOpenLeft(0.25, 0.75))); + EXPECT_TRUE(interval.contains(Interval::HalfOpenRight(0.25, 0.75))); + EXPECT_TRUE(interval.contains(Interval::Open(0.25, 0.75))); + } + + { + EXPECT_TRUE(interval.contains(Interval::Closed(0.0, 1.0))); + EXPECT_TRUE(interval.contains(Interval::HalfOpenLeft(0.0, 1.0))); + EXPECT_TRUE(interval.contains(Interval::HalfOpenRight(0.0, 1.0))); + EXPECT_TRUE(interval.contains(Interval::Open(0.0, 1.0))); + } + + { + EXPECT_FALSE(interval.contains(Interval::Closed(-1.0, 2.0))); + EXPECT_FALSE(interval.contains(Interval::HalfOpenLeft(-1.0, 2.0))); + EXPECT_FALSE(interval.contains(Interval::HalfOpenRight(-1.0, 2.0))); + EXPECT_FALSE(interval.contains(Interval::Open(-1.0, 2.0))); + } + + { + EXPECT_FALSE(interval.contains(Interval::Closed(0.5, 1.5))); + EXPECT_FALSE(interval.contains(Interval::HalfOpenLeft(0.5, 1.5))); + EXPECT_FALSE(interval.contains(Interval::HalfOpenRight(0.5, 1.5))); + EXPECT_FALSE(interval.contains(Interval::Open(0.0, 1.5))); + } + + { + EXPECT_FALSE(interval.contains(Interval::Closed(1.0, 2.0))); + EXPECT_FALSE(interval.contains(Interval::HalfOpenLeft(1.0, 2.0))); + EXPECT_FALSE(interval.contains(Interval::HalfOpenRight(1.0, 2.0))); + EXPECT_FALSE(interval.contains(Interval::Open(1.0, 2.0))); + } + + { + EXPECT_FALSE(interval.contains(Interval::Closed(2.0, 3.0))); + EXPECT_FALSE(interval.contains(Interval::HalfOpenLeft(2.0, 3.0))); + EXPECT_FALSE(interval.contains(Interval::HalfOpenRight(2.0, 3.0))); + EXPECT_FALSE(interval.contains(Interval::Open(2.0, 3.0))); + } + } + + { + const Interval interval = Interval::HalfOpenLeft(0.0, 1.0); + + { + EXPECT_ANY_THROW(interval.contains(Interval::Undefined())); + EXPECT_ANY_THROW(Interval::Undefined().contains(interval)); + } + + { + EXPECT_FALSE(interval.contains(Interval::Closed(-2.0, -1.0))); + EXPECT_FALSE(interval.contains(Interval::HalfOpenLeft(-2.0, -1.0))); + EXPECT_FALSE(interval.contains(Interval::HalfOpenRight(-2.0, -1.0))); + EXPECT_FALSE(interval.contains(Interval::Open(-2.0, -1.0))); + } + + { + EXPECT_FALSE(interval.contains(Interval::Closed(-1.0, 0.0))); + EXPECT_FALSE(interval.contains(Interval::HalfOpenLeft(-1.0, 0.0))); + EXPECT_FALSE(interval.contains(Interval::HalfOpenRight(-1.0, 0.0))); + EXPECT_FALSE(interval.contains(Interval::Open(-1.0, 0.0))); + } + + { + EXPECT_FALSE(interval.contains(Interval::Closed(-1.0, 0.5))); + EXPECT_FALSE(interval.contains(Interval::HalfOpenLeft(-1.0, 0.5))); + EXPECT_FALSE(interval.contains(Interval::HalfOpenRight(-1.0, 0.5))); + EXPECT_FALSE(interval.contains(Interval::Open(-1.0, 0.5))); + } + + { + EXPECT_TRUE(interval.contains(Interval::Closed(0.25, 0.75))); + EXPECT_TRUE(interval.contains(Interval::HalfOpenLeft(0.25, 0.75))); + EXPECT_TRUE(interval.contains(Interval::HalfOpenRight(0.25, 0.75))); + EXPECT_TRUE(interval.contains(Interval::Open(0.25, 0.75))); + } + + { + EXPECT_FALSE(interval.contains(Interval::Closed(0.0, 1.0))); + EXPECT_TRUE(interval.contains(Interval::HalfOpenLeft(0.0, 1.0))); + EXPECT_FALSE(interval.contains(Interval::HalfOpenRight(0.0, 1.0))); + EXPECT_TRUE(interval.contains(Interval::Open(0.0, 1.0))); + } + + { + EXPECT_FALSE(interval.contains(Interval::Closed(-1.0, 2.0))); + EXPECT_FALSE(interval.contains(Interval::HalfOpenLeft(-1.0, 2.0))); + EXPECT_FALSE(interval.contains(Interval::HalfOpenRight(-1.0, 2.0))); + EXPECT_FALSE(interval.contains(Interval::Open(-1.0, 2.0))); + } + + { + EXPECT_FALSE(interval.contains(Interval::Closed(0.5, 1.5))); + EXPECT_FALSE(interval.contains(Interval::HalfOpenLeft(0.5, 1.5))); + EXPECT_FALSE(interval.contains(Interval::HalfOpenRight(0.5, 1.5))); + EXPECT_FALSE(interval.contains(Interval::Open(0.0, 1.5))); + } + + { + EXPECT_FALSE(interval.contains(Interval::Closed(1.0, 2.0))); + EXPECT_FALSE(interval.contains(Interval::HalfOpenLeft(1.0, 2.0))); + EXPECT_FALSE(interval.contains(Interval::HalfOpenRight(1.0, 2.0))); + EXPECT_FALSE(interval.contains(Interval::Open(1.0, 2.0))); + } + + { + EXPECT_FALSE(interval.contains(Interval::Closed(2.0, 3.0))); + EXPECT_FALSE(interval.contains(Interval::HalfOpenLeft(2.0, 3.0))); + EXPECT_FALSE(interval.contains(Interval::HalfOpenRight(2.0, 3.0))); + EXPECT_FALSE(interval.contains(Interval::Open(2.0, 3.0))); + } + } + + { + const Interval interval = Interval::HalfOpenRight(0.0, 1.0); + + { + EXPECT_ANY_THROW(interval.contains(Interval::Undefined())); + EXPECT_ANY_THROW(Interval::Undefined().contains(interval)); + } + + { + EXPECT_FALSE(interval.contains(Interval::Closed(-2.0, -1.0))); + EXPECT_FALSE(interval.contains(Interval::HalfOpenLeft(-2.0, -1.0))); + EXPECT_FALSE(interval.contains(Interval::HalfOpenRight(-2.0, -1.0))); + EXPECT_FALSE(interval.contains(Interval::Open(-2.0, -1.0))); + } + + { + EXPECT_FALSE(interval.contains(Interval::Closed(-1.0, 0.0))); + EXPECT_FALSE(interval.contains(Interval::HalfOpenLeft(-1.0, 0.0))); + EXPECT_FALSE(interval.contains(Interval::HalfOpenRight(-1.0, 0.0))); + EXPECT_FALSE(interval.contains(Interval::Open(-1.0, 0.0))); + } + + { + EXPECT_FALSE(interval.contains(Interval::Closed(-1.0, 0.5))); + EXPECT_FALSE(interval.contains(Interval::HalfOpenLeft(-1.0, 0.5))); + EXPECT_FALSE(interval.contains(Interval::HalfOpenRight(-1.0, 0.5))); + EXPECT_FALSE(interval.contains(Interval::Open(-1.0, 0.5))); + } + + { + EXPECT_TRUE(interval.contains(Interval::Closed(0.25, 0.75))); + EXPECT_TRUE(interval.contains(Interval::HalfOpenLeft(0.25, 0.75))); + EXPECT_TRUE(interval.contains(Interval::HalfOpenRight(0.25, 0.75))); + EXPECT_TRUE(interval.contains(Interval::Open(0.25, 0.75))); + } + + { + EXPECT_FALSE(interval.contains(Interval::Closed(0.0, 1.0))); + EXPECT_FALSE(interval.contains(Interval::HalfOpenLeft(0.0, 1.0))); + EXPECT_TRUE(interval.contains(Interval::HalfOpenRight(0.0, 1.0))); + EXPECT_TRUE(interval.contains(Interval::Open(0.0, 1.0))); + } + + { + EXPECT_FALSE(interval.contains(Interval::Closed(-1.0, 2.0))); + EXPECT_FALSE(interval.contains(Interval::HalfOpenLeft(-1.0, 2.0))); + EXPECT_FALSE(interval.contains(Interval::HalfOpenRight(-1.0, 2.0))); + EXPECT_FALSE(interval.contains(Interval::Open(-1.0, 2.0))); + } + + { + EXPECT_FALSE(interval.contains(Interval::Closed(0.5, 1.5))); + EXPECT_FALSE(interval.contains(Interval::HalfOpenLeft(0.5, 1.5))); + EXPECT_FALSE(interval.contains(Interval::HalfOpenRight(0.5, 1.5))); + EXPECT_FALSE(interval.contains(Interval::Open(0.0, 1.5))); + } + + { + EXPECT_FALSE(interval.contains(Interval::Closed(1.0, 2.0))); + EXPECT_FALSE(interval.contains(Interval::HalfOpenLeft(1.0, 2.0))); + EXPECT_FALSE(interval.contains(Interval::HalfOpenRight(1.0, 2.0))); + EXPECT_FALSE(interval.contains(Interval::Open(1.0, 2.0))); + } + + { + EXPECT_FALSE(interval.contains(Interval::Closed(2.0, 3.0))); + EXPECT_FALSE(interval.contains(Interval::HalfOpenLeft(2.0, 3.0))); + EXPECT_FALSE(interval.contains(Interval::HalfOpenRight(2.0, 3.0))); + EXPECT_FALSE(interval.contains(Interval::Open(2.0, 3.0))); + } + } + + { + const Interval interval = Interval::Open(0.0, 1.0); + + { + EXPECT_ANY_THROW(interval.contains(Interval::Undefined())); + EXPECT_ANY_THROW(Interval::Undefined().contains(interval)); + } + + { + EXPECT_FALSE(interval.contains(Interval::Closed(-2.0, -1.0))); + EXPECT_FALSE(interval.contains(Interval::HalfOpenLeft(-2.0, -1.0))); + EXPECT_FALSE(interval.contains(Interval::HalfOpenRight(-2.0, -1.0))); + EXPECT_FALSE(interval.contains(Interval::Open(-2.0, -1.0))); + } + + { + EXPECT_FALSE(interval.contains(Interval::Closed(-1.0, 0.0))); + EXPECT_FALSE(interval.contains(Interval::HalfOpenLeft(-1.0, 0.0))); + EXPECT_FALSE(interval.contains(Interval::HalfOpenRight(-1.0, 0.0))); + EXPECT_FALSE(interval.contains(Interval::Open(-1.0, 0.0))); + } + + { + EXPECT_FALSE(interval.contains(Interval::Closed(-1.0, 0.5))); + EXPECT_FALSE(interval.contains(Interval::HalfOpenLeft(-1.0, 0.5))); + EXPECT_FALSE(interval.contains(Interval::HalfOpenRight(-1.0, 0.5))); + EXPECT_FALSE(interval.contains(Interval::Open(-1.0, 0.5))); + } + + { + EXPECT_TRUE(interval.contains(Interval::Closed(0.25, 0.75))); + EXPECT_TRUE(interval.contains(Interval::HalfOpenLeft(0.25, 0.75))); + EXPECT_TRUE(interval.contains(Interval::HalfOpenRight(0.25, 0.75))); + EXPECT_TRUE(interval.contains(Interval::Open(0.25, 0.75))); + } + + { + EXPECT_FALSE(interval.contains(Interval::Closed(0.0, 1.0))); + EXPECT_FALSE(interval.contains(Interval::HalfOpenLeft(0.0, 1.0))); + EXPECT_FALSE(interval.contains(Interval::HalfOpenRight(0.0, 1.0))); + EXPECT_TRUE(interval.contains(Interval::Open(0.0, 1.0))); + } + + { + EXPECT_FALSE(interval.contains(Interval::Closed(-1.0, 2.0))); + EXPECT_FALSE(interval.contains(Interval::HalfOpenLeft(-1.0, 2.0))); + EXPECT_FALSE(interval.contains(Interval::HalfOpenRight(-1.0, 2.0))); + EXPECT_FALSE(interval.contains(Interval::Open(-1.0, 2.0))); + } + + { + EXPECT_FALSE(interval.contains(Interval::Closed(0.5, 1.5))); + EXPECT_FALSE(interval.contains(Interval::HalfOpenLeft(0.5, 1.5))); + EXPECT_FALSE(interval.contains(Interval::HalfOpenRight(0.5, 1.5))); + EXPECT_FALSE(interval.contains(Interval::Open(0.0, 1.5))); + } + + { + EXPECT_FALSE(interval.contains(Interval::Closed(1.0, 2.0))); + EXPECT_FALSE(interval.contains(Interval::HalfOpenLeft(1.0, 2.0))); + EXPECT_FALSE(interval.contains(Interval::HalfOpenRight(1.0, 2.0))); + EXPECT_FALSE(interval.contains(Interval::Open(1.0, 2.0))); + } + + { + EXPECT_FALSE(interval.contains(Interval::Closed(2.0, 3.0))); + EXPECT_FALSE(interval.contains(Interval::HalfOpenLeft(2.0, 3.0))); + EXPECT_FALSE(interval.contains(Interval::HalfOpenRight(2.0, 3.0))); + EXPECT_FALSE(interval.contains(Interval::Open(2.0, 3.0))); + } + } +} TEST(OpenSpaceToolkit_Mathematics_Object_Interval, AccessLowerBound) {