private static void TestIntervalOps(S1Interval x, S1Interval y, string expected_relation, S1Interval expected_union, S1Interval expected_intersection) { // Test all of the interval operations on the given pair of intervals. // "expected_relation" is a sequence of "T" and "F" characters corresponding // to the expected results of Contains(), InteriorContains(), Intersects(), // and InteriorIntersects() respectively. Assert.Equal(x.Contains(y), expected_relation[0] == 'T'); Assert.Equal(x.InteriorContains(y), expected_relation[1] == 'T'); Assert.Equal(x.Intersects(y), expected_relation[2] == 'T'); Assert.Equal(x.InteriorIntersects(y), expected_relation[3] == 'T'); // bounds() returns a reference to a member variable, so we need to // make a copy when invoking it on a temporary object. Assert.Equal(R2Point.FromCoords(x.Union(y).Bounds()).Bounds(), expected_union.Bounds()); Assert.Equal(R2Point.FromCoords(x.Intersection(y).Bounds()).Bounds(), expected_intersection.Bounds()); Assert.Equal(x.Contains(y), x.Union(y) == x); Assert.Equal(x.Intersects(y), !x.Intersection(y).IsEmpty()); if (y.Lo == y.Hi) { var r = S1Interval.AddPoint(x, y.Lo); Assert.Equal(r.Bounds(), expected_union.Bounds()); } }