public void TestGT_02() { for (int i = 0; i < 100; i++) { int i1 = Random.Next(int.MinValue, int.MaxValue); IValueSet <int> values = ForInt.Related(GreaterThan, i1); Assert.Equal($"[{i1 + 1}..{int.MaxValue}]", values.ToString()); } }
public void TestLE_02() { for (int i = 0; i < 100; i++) { int i1 = Random.Next(int.MinValue, int.MaxValue) + 1; IValueSet <int> values = ForInt.Related(LessThanOrEqual, i1); Assert.Equal($"[{int.MinValue}..{i1}]", values.ToString()); } }
public void TestGT_01(int i1) { IValueSet <int> values = ForInt.Related(GreaterThan, i1); Assert.Equal( (i1 == int.MaxValue) ? "" : $"[{i1 + 1}..{int.MaxValue}]", values.ToString() ); }
public void TestLT_01(int i1) { IValueSet <int> values = ForInt.Related(LessThan, i1); Assert.Equal( (i1 == int.MinValue) ? "" : $"[{int.MinValue}..{i1 - 1}]", values.ToString() ); }
public void TestIsEmpty_01() { for (int i = 0; i < 100; i++) { int i1 = Random.Next(int.MinValue, int.MaxValue); int i2 = Random.Next(int.MinValue, int.MaxValue); IValueSet <int> values = ForInt.Related(GreaterThanOrEqual, i1).Intersect(ForInt.Related(LessThanOrEqual, i2)); Assert.Equal(values.ToString().Length == 0, values.IsEmpty); } }
public void TestDouble_01() { for (int i = 0; i < 100; i++) { double d1 = Random.NextDouble() * 100 - 50; double d2 = Random.NextDouble() * 100 - 50; if (d1 > d2) { (d1, d2) = (d2, d1); } IValueSet <double> values = ForDouble.Related(GreaterThanOrEqual, d1).Intersect(ForDouble.Related(LessThanOrEqual, d2)); Assert.Equal(FormattableString.Invariant($"[{d1:G17}..{d2:G17}]"), values.ToString()); } }
public void TestUnion_02() { 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); } IValueSet <int> values1 = ForInt.Related(LessThanOrEqual, i1).Union(ForInt.Related(GreaterThanOrEqual, i2)); Assert.Equal($"[{int.MinValue}..{int.MaxValue}]", values1.ToString()); IValueSet <int> values2 = ForInt.Related(GreaterThanOrEqual, i2).Union(ForInt.Related(LessThanOrEqual, i1)); Assert.Equal(values1, values2); } }
public void TestIntersect_02() { 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 == i2) { continue; } IValueSet <int> values1 = ForInt.Related(GreaterThanOrEqual, i1).Intersect(ForInt.Related(LessThanOrEqual, i2)); Assert.Equal($"", values1.ToString()); IValueSet <int> values2 = ForInt.Related(LessThanOrEqual, i2).Intersect(ForInt.Related(GreaterThanOrEqual, i1)); Assert.Equal(values1, values2); } }
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 void TestAny_01() { for (int i = 0; i < 100; i++) { int i1 = Random.Next(int.MinValue, int.MaxValue); int i2 = Random.Next(int.MinValue, int.MaxValue); if (i1 > i2) { (i1, i2) = (i2, i1); } IValueSet <int> values = ForInt .Related(GreaterThanOrEqual, i1) .Intersect(ForInt.Related(LessThanOrEqual, i2)); Assert.Equal($"[{i1}..{i2}]", values.ToString()); test(int.MinValue); if (i1 != int.MinValue) { test(i1 - 1); } test(i1); test(i1 + 1); test(int.MaxValue); if (i2 != int.MinValue) { test(i2 - 1); } test(i2); test(i2 + 1); void test(int val) { Assert.Equal(val >= i1 && val <= i2, values.Any(Equal, val)); Assert.Equal(val >= i1, values.Any(LessThanOrEqual, val)); Assert.Equal(val > i1, values.Any(LessThan, val)); Assert.Equal(val <= i2, values.Any(GreaterThanOrEqual, val)); Assert.Equal(i2 > val, values.Any(GreaterThan, val)); } } }
public void TestLE_01(int i1) { IValueSet <int> values = ForInt.Related(LessThanOrEqual, i1); Assert.Equal($"[{int.MinValue}..{i1}]", values.ToString()); }
public void TestGE_01(int i1) { IValueSet <int> values = ForInt.Related(GreaterThanOrEqual, i1); Assert.Equal($"[{i1}..{int.MaxValue}]", values.ToString()); }
public void TestEQ_01(int i1) { IValueSet <int> values = ForInt.Related(Equal, i1); Assert.Equal($"[{i1}..{i1}]", values.ToString()); }