public void TestDouble_Cov_01() { var s1 = ForDouble.Related(LessThan, 3.14d); IValueSet b = s1; Assert.Same(s1, s1.Intersect(s1)); Assert.Same(s1, s1.Union(s1)); var s2 = ForDouble.Related(GreaterThan, 31.4d); var s3 = b.Complement().Intersect(s2.Complement()); Assert.Equal("NaN,[3.1400000000000001..31.399999999999999]", s3.ToString()); var s4 = b.Union(s2).Complement(); Assert.Equal(s3, s4); }
public void TestComplement_01() { for (int i = 0; i < 100; i++) { int i1 = Random.Next(int.MinValue + 1, int.MaxValue); int i2 = Random.Next(int.MinValue, int.MaxValue); if (i1 > i2) { (i1, i2) = (i2, i1); } if ((i1 + 1) >= i2) { continue; } IValueSet <int> values1 = ForInt.Related(LessThanOrEqual, i1).Union(ForInt.Related(GreaterThanOrEqual, i2)); Assert.Equal($"[{int.MinValue}..{i1}],[{i2}..{int.MaxValue}]", values1.ToString()); IValueSet <int> values2 = values1.Complement(); Assert.Equal(values1, values2.Complement()); Assert.Equal($"[{i1 + 1}..{i2 - 1}]", values2.ToString()); } }
public IValueSet Subtract(IValueSet other) { return(this.Intersect(other.Complement())); }