Exemplo n.º 1
0
        public void EmptyTree_ContainsKey_ReturnsFalse()
        {
            RBTree <int> tree           = new RBTree <int>(intComparison);
            int          notInserted    = 5;
            bool         containsResult = tree.Contains(notInserted);

            Assert.IsFalse(containsResult);
        }
Exemplo n.º 2
0
        public void InsertKey_ContainsThisKey_ReturnsTrue()
        {
            RBTree <int> tree = new RBTree <int>(intComparison);
            int          key  = 0;

            tree.Insert(key);
            bool containsResult = tree.Contains(key);

            Assert.IsTrue(containsResult);
        }
Exemplo n.º 3
0
        public void InsertOneKey_ContainsAnotherKey_ReturnsFalse()
        {
            RBTree <int> tree        = new RBTree <int>(intComparison);
            int          addedKey    = 0;
            int          notAddedKey = -1;

            tree.Insert(addedKey);
            bool containsResult = tree.Contains(notAddedKey);

            Assert.IsFalse(containsResult);
        }
Exemplo n.º 4
0
        public void Insert10Keys_ContainsNonExistentKey_ReturnsFalse()
        {
            RBTree <int> tree = new RBTree <int>(intComparison);
            int          size = 10;

            int[] keys = new int[size];
            for (int i = 0; i < size; i++)
            {
                keys[i] = i;
                tree.Insert(keys[i]);
            }
            int  notExistKey    = int.MinValue;
            bool containsResult = tree.Contains(notExistKey);

            Assert.IsFalse(containsResult);
        }
Exemplo n.º 5
0
        public void Insert100Keys_ContainsKeys_ReturnTrue()
        {
            RBTree <int> tree = new RBTree <int>(intComparison);
            int          size = 100;

            int[] keys = new int[size];
            for (int i = 0; i < size; i++)
            {
                keys[i] = i;
                tree.Insert(keys[i]);
            }

            bool containsAll = true;

            for (int i = 0; i < size; i++)
            {
                containsAll = containsAll && tree.Contains(keys[i]);
            }
        }