Commit d300ab79 authored by Lukas Jelonek's avatar Lukas Jelonek
Browse files

Fixed Bug: Wrong behaviour of contains for empty snd interval

parent 983e9275
......@@ -43,7 +43,8 @@ public class IntegerIntervalOperations implements IntervalOperations<Integer> {
fst = fst.as(Interval.Type.ZeroOpen);
snd = snd.as(Interval.Type.ZeroOpen);
return fst.getStart() <= snd.getStart() && fst.getEnd() >= snd.getEnd();
return fst.getStart() <= snd.getStart() && fst.getEnd() >= snd.getEnd() // inside borders
&& snd.getStart() < fst.getEnd(); // for empty snd interval
}
@Override
......@@ -253,4 +254,6 @@ public class IntegerIntervalOperations implements IntervalOperations<Integer> {
}
return Intervals.createInterval(min, max);
}
}
......@@ -43,7 +43,9 @@ public class IntegerIntervalContainsOperationTest {
// same intervals
{Intervals.createInterval(0, 10), Intervals.createInterval(0, 10), true},
// not contained
{Intervals.createInterval(0, 10), Intervals.createInterval(2, 11), false}
{Intervals.createInterval(0, 10), Intervals.createInterval(2, 11), false},
// empty interval at end
{Intervals.createInterval(0, 10), Intervals.createInterval(10, 10), false}
});
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment