public void IntersectWith_WithSameInterval_ReturnsOriginalReference(bool aStartInclusive, bool aEndInclusive) { var intervalA = new IntegerInterval(0, aStartInclusive, 3, aEndInclusive); var actual = intervalA.IntersectWith(intervalA); Assert.That(actual, Is.EqualTo(intervalA)); }
public void IntersectWith_WhenIntervalsDoNotIntersect_ReturnsNull(bool aStartInclusive, bool aEndInclusive, bool bStartInclusive, bool bEndInclusive) { var intervalA = new IntegerInterval(0, aStartInclusive, 1, aEndInclusive); var intervalB = new IntegerInterval(2, bStartInclusive, 3, bEndInclusive); var actual = intervalA.IntersectWith(intervalB); Assert.That(actual, Is.Null); }
public void IntersectWith_WithWhollyContianedInterval_ReturnsContainedInterval(bool aStartInclusive, bool aEndInclusive, bool bStartInclusive, bool bEndInclusive) { var intervalA = new IntegerInterval(0, aStartInclusive, 3, aEndInclusive); var intervalB = new IntegerInterval(1, bStartInclusive, 2, bEndInclusive); var actual = intervalA.IntersectWith(intervalB); Assert.That(actual, Is.EqualTo(intervalB)); }
public void IntersectWith_FromEmptyInterval_ReturnsNull(int aStart, bool aStartInclusive, int aEnd, bool aEndInclusive, bool bStartInclusive, bool bEndInclusive) { var intervalA = new IntegerInterval(aStart, aStartInclusive, aEnd, aEndInclusive); var intervalB = new IntegerInterval(1, bStartInclusive, 0, bEndInclusive); var actual = intervalA.IntersectWith(intervalB); Assert.That(actual, Is.Null); }
public void IntersectWith_WhenIntervalsIntersectInAnExclusivePoint_ReturnsNull(bool aStartInclusive, bool aEndInclusive, bool bStartInclusive, bool bEndInclusive) { Assume.That(!aEndInclusive || !bStartInclusive); var intervalA = new IntegerInterval(0, aStartInclusive, 2, aEndInclusive); var intervalB = new IntegerInterval(2, bStartInclusive, 3, bEndInclusive); var actual = intervalA.IntersectWith(intervalB); Assert.That(actual, Is.Null); }
public void IntersectWith_WhenIntervalsIntersectInAPoint_ReturnsThatPointWithMatchingInclusivity(bool aStartInclusive, bool bEndInclusive) { var intervalA = new IntegerInterval(0, aStartInclusive, 2, true); var intervalB = new IntegerInterval(2, true, 3, bEndInclusive); var actual = intervalA.IntersectWith(intervalB); Assert.That(actual.Start, Is.EqualTo(intervalB.Start)); Assert.That(actual.End, Is.EqualTo(intervalA.End)); Assert.That(actual.StartInclusive && actual.EndInclusive, Is.EqualTo(true)); }
public void IntersectWith_WhenOtherIntervalIsEmpty_ReturnsNull(int aStart, bool aStartInclusive, int aEnd, bool aEndInclusive, int bStartAndEnd, bool bStartInclusive, bool bEndInclusive) { Assume.That(!bStartInclusive || !bEndInclusive); var intervalA = new IntegerInterval(aStart, aStartInclusive, aEnd, aEndInclusive); var intervalB = new IntegerInterval(0, false, 0, false); var actual = intervalA.IntersectWith(intervalB); Assert.That(actual, Is.Null); }
public void IntersectWith_WhenIntervalsIntersectInAIntervalReversed_ReturnsThatIntervalWithMatchingInclusivity(bool aStartInclusive, bool aEndInclusive, bool bStartInclusive, bool bEndInclusive) { var intervalA = new IntegerInterval(0, aStartInclusive, 2, aEndInclusive); var intervalB = new IntegerInterval(1, bStartInclusive, 3, bEndInclusive); var actual = intervalB.IntersectWith(intervalA); Assert.That(actual.Start, Is.EqualTo(intervalB.Start)); Assert.That(actual.StartInclusive, Is.EqualTo(intervalB.StartInclusive)); Assert.That(actual.End, Is.EqualTo(intervalA.End)); Assert.That(actual.EndInclusive, Is.EqualTo(intervalA.EndInclusive)); }
public void IntersectWith_WhenIntervalsAreSameSize_ReturnsIntervalWithMostRestrictedInclusivity(bool aStartInclusive, bool aEndInclusive, bool bStartInclusive, bool bEndInclusive) { var intervalA = new IntegerInterval(0, aStartInclusive, 3, aEndInclusive); var intervalB = new IntegerInterval(0, bStartInclusive, 3, bEndInclusive); var actual = intervalA.IntersectWith(intervalB); Assert.That(actual.Start, Is.EqualTo(intervalB.Start)); Assert.That(actual.StartInclusive, Is.EqualTo(intervalA.StartInclusive && intervalB.StartInclusive)); Assert.That(actual.End, Is.EqualTo(intervalA.End)); Assert.That(actual.EndInclusive, Is.EqualTo(intervalA.EndInclusive && intervalB.EndInclusive)); }
public void IntersectWith_WhenIntervalsAreSameSizeAndThisIntervalMatchesMostRestrictive_ReturnsThisInterval(bool aStartInclusive, bool aEndInclusive, bool bStartInclusive, bool bEndInclusive) { Assume.That(bStartInclusive || bEndInclusive); Assume.That(bStartInclusive || (!bStartInclusive && !aStartInclusive)); Assume.That(bEndInclusive || (!bEndInclusive && !aEndInclusive)); var intervalA = new IntegerInterval(0, aStartInclusive, 3, aEndInclusive); var intervalB = new IntegerInterval(0, bStartInclusive, 3, bEndInclusive); var actual = intervalA.IntersectWith(intervalB); Assert.That(actual, Is.EqualTo(intervalA)); }
public void IntersectWith_WithEmptyInterval_ReturnsNull(bool aStartInclusive, bool aEndInclusive, int bStart, bool bStartInclusive, int bEnd, bool bEndInclusive) { var intervalA = new IntegerInterval(1, aStartInclusive, 0, aEndInclusive); var intervalB = new IntegerInterval(bStart, bStartInclusive, bEnd, bEndInclusive); var actual = intervalA.IntersectWith(intervalB); Assert.That(actual, Is.Null); }
public void IntersectWith_WhenThisIntervalIsEmpty_ReturnsNull(int aStartAndEnd, bool aStartInclusive, bool aEndInclusive, int bStart, bool bStartInclusive, int bEnd, bool bEndInclusive) { Assume.That(!aStartInclusive || !aEndInclusive); var intervalA = new IntegerInterval(aStartAndEnd, aStartInclusive, aStartAndEnd, aEndInclusive); var intervalB = new IntegerInterval(bStart, bStartInclusive, bEnd, bEndInclusive); var actual = intervalA.IntersectWith(intervalB); Assert.That(actual, Is.Null); }
public void IntersectWith_WhenIntervalsIntersectInAPoint_ReturnsThatPointWithMatchingInclusivity(bool aStartInclusive, bool bEndInclusive) { var intervalA = new IntegerInterval(0, aStartInclusive, 2, true); var intervalB = new IntegerInterval(2, true, 3, bEndInclusive); var actual = intervalA.IntersectWith(intervalB); Assert.That(actual.Start, Is.EqualTo(intervalB.Start)); Assert.That(actual.End, Is.EqualTo(intervalA.End)); Assert.That(actual.StartInclusive && actual.EndInclusive, Is.EqualTo(true)); }
public void IntersectWith_WhenIntervalsIntersectInAnExclusivePoint_ReturnsNull(bool aStartInclusive, bool aEndInclusive, bool bStartInclusive, bool bEndInclusive) { Assume.That(!aEndInclusive || !bStartInclusive); var intervalA = new IntegerInterval(0, aStartInclusive, 2, aEndInclusive); var intervalB = new IntegerInterval(2, bStartInclusive, 3, bEndInclusive); var actual = intervalA.IntersectWith(intervalB); Assert.That(actual, Is.Null); }
public void IntersectWith_WhenIntervalsIntersectInAIntervalReversed_ReturnsThatIntervalWithMatchingInclusivity(bool aStartInclusive, bool aEndInclusive, bool bStartInclusive, bool bEndInclusive) { var intervalA = new IntegerInterval(0, aStartInclusive, 2, aEndInclusive); var intervalB = new IntegerInterval(1, bStartInclusive, 3, bEndInclusive); var actual = intervalB.IntersectWith(intervalA); Assert.That(actual.Start, Is.EqualTo(intervalB.Start)); Assert.That(actual.StartInclusive, Is.EqualTo(intervalB.StartInclusive)); Assert.That(actual.End, Is.EqualTo(intervalA.End)); Assert.That(actual.EndInclusive, Is.EqualTo(intervalA.EndInclusive)); }
public void IntersectWith_WhenIntervalsDoNotIntersect_ReturnsNull(bool aStartInclusive, bool aEndInclusive, bool bStartInclusive, bool bEndInclusive) { var intervalA = new IntegerInterval(0, aStartInclusive, 1, aEndInclusive); var intervalB = new IntegerInterval(2, bStartInclusive, 3, bEndInclusive); var actual = intervalA.IntersectWith(intervalB); Assert.That(actual, Is.Null); }
public void IntersectWith_WhenIntervalsAreSameSize_ReturnsIntervalWithMostRestrictedInclusivity(bool aStartInclusive, bool aEndInclusive, bool bStartInclusive, bool bEndInclusive) { var intervalA = new IntegerInterval(0, aStartInclusive, 3, aEndInclusive); var intervalB = new IntegerInterval(0, bStartInclusive, 3, bEndInclusive); var actual = intervalA.IntersectWith(intervalB); Assert.That(actual.Start, Is.EqualTo(intervalB.Start)); Assert.That(actual.StartInclusive, Is.EqualTo(intervalA.StartInclusive && intervalB.StartInclusive)); Assert.That(actual.End, Is.EqualTo(intervalA.End)); Assert.That(actual.EndInclusive, Is.EqualTo(intervalA.EndInclusive && intervalB.EndInclusive)); }
public void IntersectWith_WithSameInterval_ReturnsOriginalReference(bool aStartInclusive, bool aEndInclusive) { var intervalA = new IntegerInterval(0, aStartInclusive, 3, aEndInclusive); var actual = intervalA.IntersectWith(intervalA); Assert.That(actual, Is.EqualTo(intervalA)); }
public void IntersectWith_WithWhollyContianedInterval_ReturnsContainedInterval(bool aStartInclusive, bool aEndInclusive, bool bStartInclusive, bool bEndInclusive) { var intervalA = new IntegerInterval(0, aStartInclusive, 3, aEndInclusive); var intervalB = new IntegerInterval(1, bStartInclusive, 2, bEndInclusive); var actual = intervalA.IntersectWith(intervalB); Assert.That(actual, Is.EqualTo(intervalB)); }
public void IntersectWith_WhenIntervalsAreSameSizeAndThisIntervalMatchesMostRestrictive_ReturnsThisInterval(bool aStartInclusive, bool aEndInclusive, bool bStartInclusive, bool bEndInclusive) { Assume.That(bStartInclusive || bEndInclusive); Assume.That(bStartInclusive || (!bStartInclusive && !aStartInclusive)); Assume.That(bEndInclusive || (!bEndInclusive && !aEndInclusive)); var intervalA = new IntegerInterval(0, aStartInclusive, 3, aEndInclusive); var intervalB = new IntegerInterval(0, bStartInclusive, 3, bEndInclusive); var actual = intervalA.IntersectWith(intervalB); Assert.That(actual, Is.EqualTo(intervalA)); }