Exemplo n.º 1
0
        public void ExceptionUniverseNotSame()
        {
            var s1 = new PascalSet(0, 50, new[] { 15, 20, 30 });
            var s2 = new PascalSet(10, 60, new[] { 15, 20, 60 });

            s1.IsSupersetOf(s2);
        }
Exemplo n.º 2
0
        public void ExceptionInvalid2()
        {
            var pascalSet = new PascalSet(10, new[] { 1, 2, 5, 6 });

            var array = new int[4];
            pascalSet.CopyTo(array, 1);
        }
Exemplo n.º 3
0
        public void ExceptionInvalid()
        {
            var s1 = new PascalSet(0, 50, new[] { 15, 20, 30 });
            var s2 = new PascalSet(10, 60, new[] { 15, 20, 60 });

            s1.IsProperSupersetOf(s2);
        }
Exemplo n.º 4
0
        public void ExceptionInvalid1()
        {
            var s1 = new PascalSet(0, 50, new[] { 15, 20, 30 });
            var s2 = new PascalSet(10, 60, new[] { 15, 20, 60 });

            s1.Union(s2);
        }
Exemplo n.º 5
0
        public void CompletedVisitor()
        {
            var pascalSet = new PascalSet(0, 50, new[] { 15, 20, 30, 40, 34 });

            var completedTrackingVisitor = new CompletedTrackingVisitor<int>();

            pascalSet.AcceptVisitor(completedTrackingVisitor);
        }
Exemplo n.º 6
0
        public void Simple()
        {
            var pascalSet1 = new PascalSet(0, 50, new[] { 15, 20, 30, 40, 34 });
            var pascalSet2 = new PascalSet(0, 50, new[] { 20, 25, 30, 35, 40 });
            var pascalSet3 = new PascalSet(0, 50, new[] { 15, 20, 30, 40, 34 });
            var pascalSet4 = new PascalSet(10, 50, new[] { 15, 20, 30, 40, 34 });

            Assert.IsTrue(pascalSet1.Equals(pascalSet3));
            Assert.IsFalse(pascalSet1.Equals(pascalSet2));
            Assert.IsFalse(pascalSet1.Equals(pascalSet4));
        }
Exemplo n.º 7
0
        public void Interface()
        {
            var s1 = new PascalSet(0, 50, new[] { 15, 20, 30, 40, 34 });
            var s2 = new PascalSet(0, 50, new[] { 15, 20, 30 });
            var s3 = new PascalSet(0, 50, new[] { 15, 20, 30, 40, 34 });

            Assert.IsTrue(((ISet)s1).IsProperSupersetOf(s2));
            Assert.IsFalse(((ISet)s2).IsProperSupersetOf(s1));
            Assert.IsFalse(((ISet)s3).IsProperSupersetOf(s1));
            Assert.IsFalse(((ISet)s1).IsProperSupersetOf(s3));
        }
Exemplo n.º 8
0
        public void Simple()
        {
            var pascalSet = new PascalSet(0, 500);
            Assert.IsFalse(pascalSet.IsReadOnly);

            pascalSet.Add(50);
            Assert.IsFalse(pascalSet.IsReadOnly);

            pascalSet.Add(100);
            Assert.IsFalse(pascalSet.IsReadOnly);
        }
Exemplo n.º 9
0
        public void Simple()
        {
            var pascalSet = new PascalSet(100);
            Assert.AreEqual(pascalSet.Capacity, 101);

            pascalSet = new PascalSet(1, 100);
            Assert.AreEqual(pascalSet.Capacity, 100);

            pascalSet = new PascalSet(55, 100);
            Assert.AreEqual(pascalSet.Capacity, 46);
        }
Exemplo n.º 10
0
        public void Simple()
        {
            var pascalSet = new PascalSet(0, 500);

            Assert.IsFalse(pascalSet.IsReadOnly);

            pascalSet.Add(50);
            Assert.IsFalse(pascalSet.IsReadOnly);

            pascalSet.Add(100);
            Assert.IsFalse(pascalSet.IsReadOnly);
        }
Exemplo n.º 11
0
        public void Simple()
        {
            var pascalSet = new PascalSet(0, 50, new[] { 20, 30, 40 });

            Assert.IsTrue(pascalSet.Contains(20));
            Assert.IsTrue(pascalSet.Contains(30));
            Assert.IsTrue(pascalSet.Contains(40));

            Assert.IsFalse(pascalSet.Contains(25));
            Assert.IsFalse(pascalSet.Contains(35));
            Assert.IsFalse(pascalSet.Contains(45));
        }
Exemplo n.º 12
0
        public void TestLowerBoundUpperBoundConstructor()
        {
            PascalSet s = new PascalSet(10, 50);

            Assert.AreEqual(s.LowerBound, 10);
            Assert.AreEqual(s.UpperBound, 50);
            Assert.AreEqual(s.Count, 0);

            for (int i = 10; i <= 50; i++)
            {
                Assert.AreEqual(s[i], false);
            }
        }
Exemplo n.º 13
0
        public void LowerBoundUpperBound()
        {
            var pascalSet = new PascalSet(10, 50);

            Assert.AreEqual(pascalSet.LowerBound, 10);
            Assert.AreEqual(pascalSet.UpperBound, 50);
            Assert.AreEqual(pascalSet.Count, 0);

            for (var i = 10; i <= 50; i++)
            {
                Assert.IsFalse(pascalSet[i]);
            }
        }
Exemplo n.º 14
0
        public void TestCompareTo()
        {
            PascalSet s1 = new PascalSet(0, 50, new int[] { 20, 30, 40 });
            PascalSet s2 = new PascalSet(0, 50, new int[] { 20, 25, 30, 40 });

            Assert.AreEqual(s1.CompareTo(s2), -1);
            Assert.AreEqual(s2.CompareTo(s1), 1);
            Assert.AreEqual(s1.CompareTo(s1), 0);

            object obj = new object();

            Assert.AreEqual(s1.CompareTo(obj), -1);
        }
Exemplo n.º 15
0
        public void Simple()
        {
            var pascalSet = new PascalSet(10, new[] { 1, 2, 5, 6 });

            var array = new int[4];
            pascalSet.CopyTo(array, 0);

            var list = new List<int>(array);

            Assert.IsTrue(list.Contains(1));
            Assert.IsTrue(list.Contains(2));
            Assert.IsTrue(list.Contains(5));
            Assert.IsTrue(list.Contains(6));
        }
Exemplo n.º 16
0
        public void TestRemove()
        {
            PascalSet s1 = new PascalSet(0, 50, new int[] { 15, 20, 30, 40, 34 });

            Assert.AreEqual(s1.Count, 5);
            Assert.AreEqual(s1.Remove(20), true);
            Assert.AreEqual(s1.Count, 4);

            Assert.AreEqual(s1.Remove(20), false);
            Assert.AreEqual(s1.Count, 4);

            Assert.AreEqual(s1.Remove(40), true);
            Assert.AreEqual(s1.Count, 3);
        }
Exemplo n.º 17
0
        public void Simple()
        {
            var s1 = new PascalSet(0, 50, new[] { 15, 20, 30, 40, 34 });

            Assert.AreEqual(s1.Count, 5);
            Assert.IsTrue(s1.Remove(20));
            Assert.AreEqual(s1.Count, 4);

            Assert.IsFalse(s1.Remove(20));
            Assert.AreEqual(s1.Count, 4);

            Assert.IsTrue(s1.Remove(40));
            Assert.AreEqual(s1.Count, 3);
        }
Exemplo n.º 18
0
        public void Simple()
        {
            var pascalSet = new PascalSet(0, 500);
            Assert.IsTrue(pascalSet.IsEmpty);

            pascalSet.Add(50);
            Assert.IsFalse(pascalSet.IsEmpty);

            pascalSet.Add(100);
            Assert.IsFalse(pascalSet.IsEmpty);

            pascalSet.Clear();
            Assert.IsTrue(pascalSet.IsEmpty);
        }
Exemplo n.º 19
0
        public void Simple()
        {
            var s1 = new PascalSet(0, 50, new[] { 15, 20, 30, 40, 34 });

            Assert.AreEqual(s1.Count, 5);
            Assert.IsTrue(s1.Remove(20));
            Assert.AreEqual(s1.Count, 4);

            Assert.IsFalse(s1.Remove(20));
            Assert.AreEqual(s1.Count, 4);

            Assert.IsTrue(s1.Remove(40));
            Assert.AreEqual(s1.Count, 3);
        }
Exemplo n.º 20
0
        public void TestCopyTo()
        {
            PascalSet set = new PascalSet(10, new int[] { 1, 2, 5, 6 });

            int[] array = new int[4];
            set.CopyTo(array, 0);

            List <int> l = new List <int>(array);

            Assert.AreEqual(l.Contains(1), true);
            Assert.AreEqual(l.Contains(2), true);
            Assert.AreEqual(l.Contains(5), true);
            Assert.AreEqual(l.Contains(6), true);
        }
Exemplo n.º 21
0
        public void Simple()
        {
            var pascalSet = new PascalSet(0, 50, new[] { 15, 20, 30, 40, 34 });

            var trackingVisitor = new TrackingVisitor<int>();

            pascalSet.AcceptVisitor(trackingVisitor);

            Assert.AreEqual(trackingVisitor.TrackingList.Count, 5);
            Assert.IsTrue(trackingVisitor.TrackingList.Contains(15));
            Assert.IsTrue(trackingVisitor.TrackingList.Contains(20));
            Assert.IsTrue(trackingVisitor.TrackingList.Contains(30));
            Assert.IsTrue(trackingVisitor.TrackingList.Contains(40));
            Assert.IsTrue(trackingVisitor.TrackingList.Contains(34));
        }
Exemplo n.º 22
0
        public void AddExample()
        {
            // Create a sample PascalSet instance
            var pascalSet = new PascalSet(100)
            {
                10, 57
            };

            // There will be two items in the set
            Assert.AreEqual(2, pascalSet.Count);

            // And the set will contain the 10th and 57th item
            Assert.IsTrue(pascalSet.Contains(10));
            Assert.IsTrue(pascalSet.Contains(57));
        }
Exemplo n.º 23
0
        public void TestAccept()
        {
            PascalSet s = new PascalSet(0, 50, new int[] { 15, 20, 30, 40, 34 });

            TrackingVisitor <int> v = new TrackingVisitor <int>();

            s.Accept(v);

            Assert.AreEqual(v.TrackingList.Count, 5);
            Assert.AreEqual(v.TrackingList.Contains(15), true);
            Assert.AreEqual(v.TrackingList.Contains(20), true);
            Assert.AreEqual(v.TrackingList.Contains(30), true);
            Assert.AreEqual(v.TrackingList.Contains(40), true);
            Assert.AreEqual(v.TrackingList.Contains(34), true);
        }
Exemplo n.º 24
0
        public void Simple()
        {
            var pascalSet = new PascalSet(0, 500);

            Assert.IsTrue(pascalSet.IsEmpty);

            pascalSet.Add(50);
            Assert.IsFalse(pascalSet.IsEmpty);

            pascalSet.Add(100);
            Assert.IsFalse(pascalSet.IsEmpty);

            pascalSet.Clear();
            Assert.IsTrue(pascalSet.IsEmpty);
        }
Exemplo n.º 25
0
        public void Simple()
        {
            var pascalSet = new PascalSet(0, 50, new[] { 15, 20, 30, 40, 34 });

            var trackingVisitor = new TrackingVisitor <int>();

            pascalSet.AcceptVisitor(trackingVisitor);

            Assert.AreEqual(trackingVisitor.TrackingList.Count, 5);
            Assert.IsTrue(trackingVisitor.TrackingList.Contains(15));
            Assert.IsTrue(trackingVisitor.TrackingList.Contains(20));
            Assert.IsTrue(trackingVisitor.TrackingList.Contains(30));
            Assert.IsTrue(trackingVisitor.TrackingList.Contains(40));
            Assert.IsTrue(trackingVisitor.TrackingList.Contains(34));
        }
Exemplo n.º 26
0
        public void TestIsEmpty()
        {
            PascalSet s = new PascalSet(0, 500);

            Assert.AreEqual(s.IsEmpty, true);

            s.Add(50);
            Assert.AreEqual(s.IsEmpty, false);

            s.Add(100);
            Assert.AreEqual(s.IsEmpty, false);

            s.Clear();
            Assert.AreEqual(s.IsEmpty, true);
        }
Exemplo n.º 27
0
        public void Simple()
        {
            var pascalSet = new PascalSet(10, new[] { 1, 2, 5, 6 });

            var array = new int[4];

            pascalSet.CopyTo(array, 0);

            var list = new List <int>(array);

            Assert.IsTrue(list.Contains(1));
            Assert.IsTrue(list.Contains(2));
            Assert.IsTrue(list.Contains(5));
            Assert.IsTrue(list.Contains(6));
        }
Exemplo n.º 28
0
        public void TestIsSubsetOf()
        {
            PascalSet s1 = new PascalSet(0, 50, new int[] { 15, 20, 30, 40, 34 });
            PascalSet s2 = new PascalSet(0, 50, new int[] { 15, 20, 30 });
            PascalSet s3 = new PascalSet(0, 50, new int[] { 15, 20, 30, 40, 34 });

            Assert.AreEqual(s1.IsSubsetOf(s2), false);
            Assert.AreEqual(s2.IsSubsetOf(s1), true);
            Assert.AreEqual(s3.IsSubsetOf(s1), true);
            Assert.AreEqual(s1.IsSubsetOf(s3), true);

            Assert.AreEqual(s1 <= s2, false);
            Assert.AreEqual(s2 <= s1, true);
            Assert.AreEqual(s3 <= s1, true);
            Assert.AreEqual(s1 <= s3, true);
        }
Exemplo n.º 29
0
        public void TestClear()
        {
            int[]     values = new int[] { 20, 30, 40 };
            PascalSet s      = new PascalSet(0, 50, values);

            Assert.AreEqual(s.Count, 3);

            s.Clear();

            for (int i = 0; i <= 50; i++)
            {
                Assert.AreEqual(s[i], false);
            }

            Assert.AreEqual(s.Count, 0);
        }
Exemplo n.º 30
0
        public void TestIsProperSupersetOf()
        {
            PascalSet s1 = new PascalSet(0, 50, new int[] { 15, 20, 30, 40, 34 });
            PascalSet s2 = new PascalSet(0, 50, new int[] { 15, 20, 30 });
            PascalSet s3 = new PascalSet(0, 50, new int[] { 15, 20, 30, 40, 34 });

            Assert.AreEqual(s1.IsProperSupersetOf(s2), true);
            Assert.AreEqual(s2.IsProperSupersetOf(s1), false);
            Assert.AreEqual(s3.IsProperSupersetOf(s1), false);
            Assert.AreEqual(s1.IsProperSupersetOf(s3), false);

            Assert.AreEqual(s1 > s2, true);
            Assert.AreEqual(s2 > s1, false);
            Assert.AreEqual(s3 > s1, false);
            Assert.AreEqual(s1 > s3, false);
        }
Exemplo n.º 31
0
        public void Simple()
        {
            var s1 = new PascalSet(0, 50, new[] { 15, 20, 30, 40, 34 });
            var s2 = new PascalSet(0, 50, new[] { 15, 20, 30 });
            var s3 = new PascalSet(0, 50, new[] { 15, 20, 30, 40, 34 });

            Assert.IsTrue(s1.IsProperSupersetOf(s2));
            Assert.IsFalse(s2.IsProperSupersetOf(s1));
            Assert.IsFalse(s3.IsProperSupersetOf(s1));
            Assert.IsFalse(s1.IsProperSupersetOf(s3));

            Assert.IsTrue(s1 > s2);
            Assert.IsFalse(s2 > s1);
            Assert.IsFalse(s3 > s1);
            Assert.IsFalse(s1 > s3);
        }
Exemplo n.º 32
0
        public void Simple()
        {
            var s1 = new PascalSet(0, 50, new[] { 15, 20, 30, 40, 34 });
            var s2 = new PascalSet(0, 50, new[] { 15, 20, 30 });
            var s3 = new PascalSet(0, 50, new[] { 15, 20, 30, 40, 34 });

            Assert.IsTrue(s1.IsProperSupersetOf(s2));
            Assert.IsFalse(s2.IsProperSupersetOf(s1));
            Assert.IsFalse(s3.IsProperSupersetOf(s1));
            Assert.IsFalse(s1.IsProperSupersetOf(s3));

            Assert.IsTrue(s1 > s2);
            Assert.IsFalse(s2 > s1);
            Assert.IsFalse(s3 > s1);
            Assert.IsFalse(s1 > s3);
        }
Exemplo n.º 33
0
        public void Simple()
        {
            var values    = new[] { 20, 30, 40 };
            var pascalSet = new PascalSet(0, 50, values);

            Assert.AreEqual(pascalSet.Count, 3);

            pascalSet.Clear();

            for (var i = 0; i <= 50; i++)
            {
                Assert.IsFalse(pascalSet[i]);
            }

            Assert.AreEqual(pascalSet.Count, 0);
        }
Exemplo n.º 34
0
        public void Simple()
        {
            var s1 = new PascalSet(0, 50, new[] { 15, 20, 30, 40, 34 });
            var s2 = new PascalSet(0, 50, new[] { 15, 20, 30 });
            var s3 = new PascalSet(0, 50, new[] { 15, 20, 30, 40, 34 });

            Assert.IsFalse(s1.IsSubsetOf(s2));
            Assert.IsTrue(s2.IsSubsetOf(s1));
            Assert.IsTrue(s3.IsSubsetOf(s1));
            Assert.IsTrue(s1.IsSubsetOf(s3));

            Assert.IsFalse(s1 <= s2);
            Assert.IsTrue(s2 <= s1);
            Assert.IsTrue(s3 <= s1);
            Assert.IsTrue(s1 <= s3);
        }
Exemplo n.º 35
0
        public void Simple()
        {
            var values = new[] { 20, 30, 40 };
            var pascalSet = new PascalSet(0, 50, values);

            Assert.AreEqual(pascalSet.Count, 3);

            pascalSet.Clear();

            for (var i = 0; i <= 50; i++)
            {
                Assert.IsFalse(pascalSet[i]);
            }

            Assert.AreEqual(pascalSet.Count, 0);
        }
Exemplo n.º 36
0
        public void SubtractExample()
        {
            // Create 2 pascal sets with various items
            var pascalSet1 = new PascalSet(0, 50, new[] { 15, 20, 30, 40, 34 });
            var pascalSet2 = new PascalSet(0, 50, new[] { 15, 20, 30 });

            // Subtract s2 from s1, obtaining another PascalSet
            var result = pascalSet1.Subtract(pascalSet2);

            // There will only be two items in the result
            Assert.AreEqual(result.Count, 2);

            // And those items will be 40, and 34
            Assert.IsTrue(result[40]);
            Assert.IsTrue(result[34]);
        }
Exemplo n.º 37
0
        public void ClearExample()
        {
            // Create a sample PascalSet instance
            var pascalSet = new PascalSet(100)
            {
                10, 57
            };

            // There will be two items in the set
            Assert.AreEqual(2, pascalSet.Count);

            // Remove all items from the set
            pascalSet.Clear();

            // There will be no items left in the set
            Assert.AreEqual(0, pascalSet.Count);
        }
Exemplo n.º 38
0
        public void CopyToExample()
        {
            // Create a sample PascalSet instance
            var pascalSet = new PascalSet(100);

            // Set a couple of values in the PascalSet
            for (var i = 0; i < 100; i += 10)
            {
                pascalSet.Add(i);
            }

            // Create an array to store the items in
            var values = new int[10];

            // Copy the items in the set to the array, at index 0
            pascalSet.CopyTo(values, 0);
        }
Exemplo n.º 39
0
        public void TestInterfaceInverse()
        {
            PascalSet s = new PascalSet(0, 50, new int[] { 15, 20, 30 });

            PascalSet inverse = (PascalSet)((ISet)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);
                }
            }
        }
Exemplo n.º 40
0
        public void Interface()
        {
            var pascalSet = new PascalSet(0, 50, new[] { 15, 20, 30 });

            var inverse = (PascalSet)((ISet)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]);
                }
            }
        }
Exemplo n.º 41
0
        public void Interface()
        {
            var pascalSet = new PascalSet(0, 50, new[] { 15, 20, 30 });

            var inverse = (PascalSet)((ISet)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]);
                }
            }
        }
Exemplo n.º 42
0
        public void Interface()
        {
            var s1 = new PascalSet(0, 50, new[] { 15, 20, 30, 40, 34 });
            var s2 = new PascalSet(0, 50, new[] { 20, 25, 30, 35, 40 });

            var intersection = (PascalSet)((ISet)s1).Intersection(s2);

            for (var i = 0; i <= 50; i++)
            {
                if ((i == 20) || (i == 30) || (i == 40))
                {
                    Assert.IsTrue(intersection[i]);
                }
                else
                {
                    Assert.IsFalse(intersection[i]);
                }
            }
        }
Exemplo n.º 43
0
        public void Interface()
        {
            var s1 = new PascalSet(0, 50, new[] { 20, 30, 40 });
            var s2 = new PascalSet(0, 50, new[] { 20, 25, 30, 35, 40 });

            var difference = (PascalSet)((ISet)s1).Subtract(s2);

            for (var i = 0; i < 50; i++)
            {
                if ((i == 25) || (i == 35))
                {
                    Assert.IsTrue(difference[i]);
                }
                else
                {
                    Assert.IsFalse(difference[i]);
                }
            }
        }
Exemplo n.º 44
0
        public void TestInterfaceDifference()
        {
            PascalSet s1 = new PascalSet(0, 50, new int[] { 20, 30, 40 });
            PascalSet s2 = new PascalSet(0, 50, new int[] { 20, 25, 30, 35, 40 });

            PascalSet difference = (PascalSet)((ISet)s1).Difference(s2);

            for (int i = 0; i < 50; i++)
            {
                if ((i == 25) || (i == 35))
                {
                    Assert.AreEqual(difference[i], true);
                }
                else
                {
                    Assert.AreEqual(difference[i], false);
                }
            }
        }
Exemplo n.º 45
0
        public void TestInterfaceIntersection()
        {
            PascalSet s1 = new PascalSet(0, 50, new int[] { 15, 20, 30, 40, 34 });
            PascalSet s2 = new PascalSet(0, 50, new int[] { 20, 25, 30, 35, 40 });

            PascalSet intersection = (PascalSet)((ISet)s1).Intersection(s2);

            for (int i = 0; i <= 50; i++)
            {
                if ((i == 20) || (i == 30) || (i == 40))
                {
                    Assert.AreEqual(intersection[i], true);
                }
                else
                {
                    Assert.AreEqual(intersection[i], false);
                }
            }
        }
Exemplo n.º 46
0
        public void IsSupersetOfExample()
        {
            // Create 3 pascal sets with various items
            var pascalSet1 = new PascalSet(0, 50, new[] { 15, 20, 30, 40, 34 });
            var pascalSet2 = new PascalSet(0, 50, new[] { 15, 20, 30 });
            var pascalSet3 = new PascalSet(0, 50, new[] { 15, 20, 30, 40, 34 });

            // s1 is a superset of s2
            Assert.IsTrue(pascalSet1.IsSupersetOf(pascalSet2));

            // s2 is not a superset of s1
            Assert.IsFalse(pascalSet2.IsSupersetOf(pascalSet1));

            // s3 is a superset of s1
            Assert.IsTrue(pascalSet3.IsSupersetOf(pascalSet1));

            // s1 is a superset of s3
            Assert.IsTrue(pascalSet1.IsSupersetOf(pascalSet3));
        }
Exemplo n.º 47
0
        public void UnionExample()
        {
            // Create 2 pascal sets with various items
            var pascalSet1 = new PascalSet(0, 50, new[] { 15, 20, 30, 40, 34 });
            var pascalSet2 = new PascalSet(0, 50, new[] { 3, 4, 20 });

            // Compute the union of set s1 and s2
            var union = pascalSet1.Union(pascalSet2);

            // The union will consist of the following items : 3, 4, 15, 20, 30, 50, 34
            Assert.AreEqual(7, union.Count);
            Assert.IsTrue(union[3]);
            Assert.IsTrue(union[4]);
            Assert.IsTrue(union[15]);
            Assert.IsTrue(union[20]);
            Assert.IsTrue(union[30]);
            Assert.IsTrue(union[40]);
            Assert.IsTrue(union[34]);
        }
Exemplo n.º 48
0
        public void Interface()
        {
            var s1 = new PascalSet(0, 50, new[] { 15, 20, 30, 40, 34 });
            var s2 = new PascalSet(0, 50, new[] { 20, 25, 30, 35, 40 });

            var intersection = (PascalSet)((ISet)s1).Intersection(s2);

            for (var i = 0; i <= 50; i++)
            {
                if ((i == 20) || (i == 30) || (i == 40))
                {
                    Assert.IsTrue(intersection[i]);
                }
                else
                {
                    Assert.IsFalse(intersection[i]);
                }
            }
        }
Exemplo n.º 49
0
        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));
        }
Exemplo n.º 50
0
        public void Simple()
        {
            var s1 = new PascalSet(0, 50, new[] { 15, 20, 30, 40, 34 });
            var s2 = new PascalSet(0, 50, new[] { 20, 25, 30, 35, 40 });

            var intersection = s1.Intersection(s2);

            for (var i = 0; i <= 50; i++)
            {
                if ((i == 20) || (i == 30) || (i == 40))
                {
                    Assert.IsTrue(intersection[i]);
                }
                else
                {
                    Assert.IsFalse(intersection[i]);
                }
            }

            var intersection2 = s1 * s2;
            Assert.IsTrue(intersection.Equals(intersection2));
        }
Exemplo n.º 51
0
        public void Interface()
        {
            var s1 = new PascalSet(0, 50, new[] { 15, 20, 30 });
            var s2 = new PascalSet(0, 50, new[] { 15, 25, 30 });
            var s3 = new PascalSet(0, 50, new[] { 1, 2, 3, 4 });

            var union = (PascalSet)((ISet)s1).Union(s2);

            Assert.AreEqual(union.Count, 4);

            for (var i = 0; i <= 50; i++)
            {
                if ((i == 15) || (i == 20) || (i == 25) || (i == 30))
                {
                    Assert.IsTrue(union[i]);
                }
                else
                {
                    Assert.IsFalse(union[i]);
                }
            }

            union = (PascalSet)((ISet)s2).Union(s3);

            Assert.AreEqual(union.Count, 7);

            for (var i = 0; i <= 50; i++)
            {
                if ((i == 15) || (i == 25) || (i == 30) || (i == 1) || (i == 2) || (i == 3) || (i == 4))
                {
                    Assert.IsTrue(union[i]);
                }
                else
                {
                    Assert.IsFalse(union[i]);
                }
            }
        }
Exemplo n.º 52
0
        public void Simple()
        {
            var pascalSet = new PascalSet(0, 100);
            Assert.IsFalse(pascalSet.IsFull);

            for (var i = 0; i <= 100; i++)
            {
                pascalSet.Add(i);

                if (i < 100)
                {
                    Assert.IsFalse(pascalSet.IsFull);
                }
                else
                {
                    Assert.IsTrue(pascalSet.IsFull);
                }
            }

            pascalSet.Clear();

            Assert.IsFalse(pascalSet.IsFull);
        }
Exemplo n.º 53
0
 public void ExceptionNullS1()
 {
     var pascalSet = new PascalSet(500);
     var p = null > pascalSet;
 }
Exemplo n.º 54
0
 public void NullSet()
 {
     var pascalSet = new PascalSet(500);
     pascalSet.Union(null);
 }
Exemplo n.º 55
0
 public void Null()
 {
     var pascalSet = new PascalSet(20);
     Assert.IsFalse(pascalSet.Equals(null));
 }
Exemplo n.º 56
0
 public void ExcetionNullOperator()
 {
     var pascalSet = new PascalSet(500);
     var newSet = null * pascalSet;
 }
Exemplo n.º 57
0
 public void ExceptionNullSet()
 {
     var pascalSet = new PascalSet(500);
     pascalSet.Intersection(null);
 }
Exemplo n.º 58
0
 public void ExceptionInvalidIntersectionOperator1()
 {
     var pascalSet = new PascalSet(0, 50, new[] { 15, 20, 30, 40, 34 });
     var a = pascalSet * null;
 }
Exemplo n.º 59
0
 public void ExceptionNullS2()
 {
     var pascalSet = new PascalSet(0, 50, new[] { 15, 20, 30 });
     var b = pascalSet > null;
 }
Exemplo n.º 60
0
 public void ExceptionNullSet()
 {
     var pascalSet = new PascalSet(500);
     pascalSet.IsProperSupersetOf(null);
 }