Exemplo n.º 1
0
        public void Remove_TrueTest()
        {
            IRBTree <int, string> target = new RBTree <int, string>();

            target.Add(1, "1");
            target.Add(5, "5");
            target.Add(2, "2");
            target.Add(12, "12");
            target.Add(4, "4");

            Assert.IsTrue(target.Remove(1));
            Assert.IsFalse(target.ContainsKey(1));
            Assert.AreEqual(4, target.Count);

            Assert.IsTrue(target.Remove(12));
            Assert.IsFalse(target.ContainsKey(12));
            Assert.AreEqual(3, target.Count);

            Assert.IsTrue(target.Remove(4));
            Assert.IsFalse(target.ContainsKey(4));
            Assert.AreEqual(2, target.Count);

            Assert.IsTrue(target.Remove(2));
            Assert.IsFalse(target.ContainsKey(2));
            Assert.AreEqual(1, target.Count);

            Assert.IsTrue(target.Remove(5));
            Assert.IsFalse(target.ContainsKey(5));
            Assert.AreEqual(0, target.Count);
        }
Exemplo n.º 2
0
        public void Contains_Test()
        {
            IRBTree <int, string> target = new RBTree <int, string>();

            target.Add(1, "1");
            target.Add(5, "5");
            target.Add(2, "2");
            target.Add(12, "12");
            target.Add(4, "4");

            Assert.IsTrue(target.ContainsKey(1));
            Assert.IsTrue(target.ContainsKey(5));
            Assert.IsTrue(target.ContainsKey(12));

            Assert.IsFalse(target.ContainsKey(33));
            Assert.IsFalse(target.ContainsKey(55));
        }
Exemplo n.º 3
0
        public void AddPair_Test()
        {
            IRBTree <int, string> target;

            target = new RBTree <int, string>();

            target.Add(new KeyValuePair <int, string>(1, "1"));
            target.Add(new KeyValuePair <int, string>(5, "5"));
            target.Add(new KeyValuePair <int, string>(2, "2"));
            target.Add(new KeyValuePair <int, string>(113, "113"));

            Assert.AreEqual(4, target.Count);
            Assert.AreEqual("5", target[5]);
            Assert.AreEqual("113", target[113]);
            Assert.IsTrue(target.ContainsKey(1));

            Assert.IsFalse(target.ContainsKey(3));
        }
Exemplo n.º 4
0
        public void Clear_TrueTest()
        {
            IRBTree <int, string> target = new RBTree <int, string>();

            target.Add(1, "1");
            target.Add(5, "5");
            target.Add(2, "2");
            target.Add(12, "12");
            target.Add(4, "4");

            target.Clear();

            Assert.AreEqual(0, target.Count);
            Assert.IsFalse(target.ContainsKey(1));

            target.Add(1, "1");
            Assert.AreEqual(1, target.Count);
            Assert.IsTrue(target.ContainsKey(1));
        }
Exemplo n.º 5
0
        public void Add_Test()
        {
            IRBTree <int, string> target;

            target = new RBTree <int, string>();

            target.Add(1, "1");
            target.Add(5, "5");
            target.Add(2, "2");
            target.Add(12, "12");
            target.Add(4, "4");

            Assert.AreEqual(5, target.Count);
            Assert.AreEqual("5", target[5]);
            Assert.AreEqual("4", target[4]);
            Assert.IsTrue(target.ContainsKey(1));

            Assert.IsFalse(target.ContainsKey(3));
        }