public void InverseExample() { // Create a sample PascalSet var pascalSet = new PascalSet(100); // Set a couple of values in the PascalSet for (var i = 0; i < 100; i += 10) { pascalSet.Add(i); } // Get the inverse of the set var inverse = pascalSet.Inverse(); // All the items that were not included in the original // set will be in the inverse. for (var i = 0; i < 100; i++) { if ((i % 10) > 0) { Assert.IsTrue(inverse[i]); } } // We'll have 91 items in the set (101 - 10) Assert.AreEqual(inverse.Count, 91); }
public void Simple() { var pascalSet = new PascalSet(0, 50, new[] { 15, 20, 30 }); var inverse = pascalSet.Inverse(); for (var i = 0; i <= 50; i++) { if ((i == 15) || (i == 20) || (i == 30)) { Assert.IsFalse(inverse[i]); } else { Assert.IsTrue(inverse[i]); } } var inverse2 = !pascalSet; Assert.IsTrue(inverse.Equals(inverse2)); }
public void TestInverse() { PascalSet s = new PascalSet(0, 50, new int[] { 15, 20, 30 }); PascalSet inverse = s.Inverse(); for (int i = 0; i <= 50; i++) { if ((i == 15) || (i == 20) || (i == 30)) { Assert.AreEqual(inverse[i], false); } else { Assert.AreEqual(inverse[i], true); } } PascalSet inverse2 = !s; Assert.AreEqual(inverse.IsEqual(inverse2), true); }