forked from OSchip/llvm-project
Have Range::overlapsWith use positive logic
Improved test to catch missing case. llvm-svn: 188304
This commit is contained in:
parent
c13c1b0f0d
commit
c514848d1b
|
@ -48,9 +48,7 @@ public:
|
||||||
/// @{
|
/// @{
|
||||||
/// \brief Whether this range overlaps with \p RHS or not.
|
/// \brief Whether this range overlaps with \p RHS or not.
|
||||||
bool overlapsWith(Range RHS) const {
|
bool overlapsWith(Range RHS) const {
|
||||||
if ((Offset + Length) <= RHS.Offset || Offset >= (RHS.Offset + RHS.Length))
|
return Offset + Length > RHS.Offset && Offset < RHS.Offset + RHS.Length;
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \brief Whether this range contains \p RHS or not.
|
/// \brief Whether this range contains \p RHS or not.
|
||||||
|
|
|
@ -353,6 +353,7 @@ TEST(Range, overlaps) {
|
||||||
EXPECT_FALSE(Range(10, 10).overlapsWith(Range(0, 10)));
|
EXPECT_FALSE(Range(10, 10).overlapsWith(Range(0, 10)));
|
||||||
EXPECT_FALSE(Range(0, 10).overlapsWith(Range(10, 10)));
|
EXPECT_FALSE(Range(0, 10).overlapsWith(Range(10, 10)));
|
||||||
EXPECT_TRUE(Range(0, 10).overlapsWith(Range(2, 6)));
|
EXPECT_TRUE(Range(0, 10).overlapsWith(Range(2, 6)));
|
||||||
|
EXPECT_TRUE(Range(2, 6).overlapsWith(Range(0, 10)));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(Range, contains) {
|
TEST(Range, contains) {
|
||||||
|
|
Loading…
Reference in New Issue