Example #1
0
        public void CountTest()
        {
            var stringSet = new GenericSet <string>();

            stringSet.Add("ohhimark");
            Assert.AreEqual(1, stringSet.Count);
        }
Example #2
0
        public void AddTest()
        {
            var intSet = new GenericSet <int>();

            intSet.Add(8);
            Assert.AreEqual(1, intSet.Count);
        }
Example #3
0
        public void ContainsTrueTest()
        {
            var intSet = new GenericSet <int>();

            intSet.Add(8);
            Assert.AreEqual(true, intSet.Contains(8));
        }
Example #4
0
        public void ContainsFalseTest()
        {
            var intSet = new GenericSet <int>();

            intSet.Add(8);
            Assert.AreEqual(false, intSet.Contains(3));
        }
Example #5
0
        public void RemoveEmptyTest()
        {
            var intSet = new GenericSet <int>();

            Assert.IsFalse(intSet.Remove(56));
            Assert.AreEqual(0, intSet.Count);
        }
Example #6
0
        public void ClearTest()
        {
            var stringSet = new GenericSet <string>();

            stringSet.Add("ohhimark");
            stringSet.Add("ohhidoggy");
            stringSet.Clear();
            Assert.AreEqual(0, stringSet.Count);
        }
Example #7
0
        public void AddExistingTest()
        {
            var intSet = new GenericSet <int>();

            intSet.Add(8);
            intSet.Add(16);
            intSet.Add(8);
            Assert.AreEqual(2, intSet.Count);
        }
Example #8
0
        public void EmptyIsProperSubsetOfTest()
        {
            var intSetFirst  = new GenericSet <int>();
            var intSetSecond = new GenericSet <int>();
            var firstData    = new int[] { 5, 16, -32, 56, 0, 5, 44, 16, 13 };

            for (int i = 0; i < firstData.Length; ++i)
            {
                intSetFirst.Add(firstData[i]);
            }
            Assert.IsTrue(intSetSecond.IsProperSubsetOf(intSetFirst));
        }
Example #9
0
        public void SetEqualsTrueTest()
        {
            var intSetFirst  = new GenericSet <int>();
            var intSetSecond = new GenericSet <int>();
            var data         = new int[] { 5, 16, -32, 56, 0, -1, 44, -112, 13 };

            for (int i = 0; i < data.Length; ++i)
            {
                intSetFirst.Add(data[i]);
                intSetSecond.Add(data[i]);
            }
            Assert.IsTrue(intSetFirst.SetEquals(intSetSecond));
        }
Example #10
0
        public void CopyToTest()
        {
            var intSet = new GenericSet <int>();

            intSet.Add(8);
            intSet.Add(54);
            intSet.Add(2);
            intSet.Add(-2);
            var check  = new int[] { 8, 2, -2, 54 };
            var output = new int[4];

            intSet.CopyTo(output, 0);
            CollectionAssert.AreEqual(check, output);
        }
Example #11
0
        public void ForeachTest()
        {
            var intSet = new GenericSet <int>();

            intSet.Add(8);
            intSet.Add(54);
            intSet.Add(2);
            intSet.Add(-2);
            var check = new int[] { 8, 2, -2, 54 };
            var i     = 0;

            foreach (var element in intSet)
            {
                Assert.AreEqual(check[i], element);
                ++i;
            }
        }
Example #12
0
        public void FalseOverlapsTest()
        {
            var intSetFirst  = new GenericSet <int>();
            var intSetSecond = new GenericSet <int>();
            var firstData    = new int[] { 5, 16, -32, 56, 0, 5, 44, 16, 13 };
            var secondData   = new int[] { -1, 2, 7, 321, 1315 };

            for (int i = 0; i < firstData.Length; ++i)
            {
                intSetFirst.Add(firstData[i]);
            }
            for (int i = 0; i < secondData.Length; ++i)
            {
                intSetSecond.Add(secondData[i]);
            }
            Assert.IsFalse(intSetFirst.Overlaps(intSetSecond));
        }
Example #13
0
        public void TrueIsSupersetOfTest()
        {
            var intSetFirst  = new GenericSet <int>();
            var intSetSecond = new GenericSet <int>();
            var firstData    = new int[] { 5, 16, -32, 56, 0, 5, 44, 16, 13 };
            var secondData   = new int[] { 5, 16, 44, 16, 13 };

            for (int i = 0; i < firstData.Length; ++i)
            {
                intSetFirst.Add(firstData[i]);
            }
            for (int i = 0; i < secondData.Length; ++i)
            {
                intSetSecond.Add(secondData[i]);
            }
            Assert.IsTrue(intSetFirst.IsSupersetOf(intSetSecond));
        }
Example #14
0
        public void RemoveTest()
        {
            var intSet = new GenericSet <int>();
            var toAdd  = new int[] { 5, 16, -32, 56, 0, -1, 44, -112, 13 };

            for (int i = 0; i < toAdd.Length; ++i)
            {
                intSet.Add(toAdd[i]);
            }
            Assert.IsTrue(intSet.Remove(56));
            Assert.IsTrue(intSet.Remove(-1));
            Assert.IsTrue(intSet.Remove(5));
            Assert.IsFalse(intSet.Remove(-1313));
            var check  = new int[] { 0, -32, -112, 16, 13, 44 };
            var output = new int[6];

            intSet.CopyTo(output, 0);
            CollectionAssert.AreEqual(check, output);
        }
Example #15
0
        public void SymmetricExceptWithTest()
        {
            var intSetFirst  = new GenericSet <int>();
            var intSetSecond = new GenericSet <int>();
            var data         = new int[] { 5, 16, -32, 56, 0, 5, 44, 16, 13 };

            for (int i = 0; i < data.Length / 2; ++i)
            {
                intSetFirst.Add(data[i]);
            }
            for (int i = data.Length / 2; i < data.Length; ++i)
            {
                intSetSecond.Add(data[i]);
            }
            intSetFirst.SymmetricExceptWith(intSetSecond);
            var check  = new int[] { 0, -32, 56, 44, 13 };
            var output = new int[intSetFirst.Count];

            intSetFirst.CopyTo(output, 0);
            CollectionAssert.AreEqual(check, output);
        }