public void TestDeleteStringAsc_2()
        {
            OrderedList <string> ord = new OrderedList <string>(true);

            ord.Add(" Ground ");
            ord.Delete("Ground");

            Assert.AreEqual(" Ground ", ord.head.value);

            ord.Delete(" Ground ");

            Assert.AreEqual(null, ord.head);
        }
Exemplo n.º 2
0
        public static void TestRemoveOrderedListIntDesc()
        {
            var list = new OrderedList <int>(false);

            Assert.AreEqual(0, list.Count(), "TestRemoveOrderedListIntDesc orderedList size must be 0, but not");
            list.Add(4);
            list.Add(3);
            list.Add(2);
            list.Add(1);
            Assert.AreEqual(4, list.Count(), "TestRemoveOrderedListIntDesc orderedList size must be 4, but not");

            var counter = 4;
            var node    = list.head;

            while (node != null)
            {
                Assert.AreEqual(counter, node.value, "Test TestRemoveOrderedListIntDesc failed. List sequence is not correct");
                counter -= 1;
                node     = node.next;
            }

            list.Delete(3);
            Assert.AreEqual(3, list.Count(), "TestRemoveOrderedListIntDesc orderedList size must be 3, but not");
            list.Delete(2);
            Assert.AreEqual(2, list.Count(), "TestRemoveOrderedListIntDesc orderedList size must be 2, but not");
            counter = 4;
            node    = list.head;
            while (node != null)
            {
                Assert.AreEqual(counter, node.value, "Test TestRemoveOrderedListIntDesc failed. List sequence is not correct");
                counter -= 3;
                node     = node.next;
            }

            list.Delete(1);
            Assert.AreEqual(1, list.Count(), "TestRemoveOrderedListIntDesc orderedList size must be 1, but not");
            counter = 4;
            node    = list.head;
            while (node != null)
            {
                Assert.AreEqual(counter, node.value, "Test TestRemoveOrderedListIntDesc failed. List sequence is not correct");
                counter -= 1;
                node     = node.next;
            }

            list.Delete(4);
            Assert.AreEqual(0, list.Count(), "TestRemoveOrderedListIntDesc orderedList size must be 0, but not");

            list.Delete(4);
            Assert.AreEqual(0, list.Count(), "TestRemoveOrderedListIntAsc orderedList size must be 0, but not");
        }
Exemplo n.º 3
0
        public void DeleteTest()
        {
            OrderedList <int> orderedListAsc = CreateOrderedList(
                true,
                0, 9, 8, 1, 2, 3, 7, 6, 5, 4);

            Assert.Equal(10, orderedListAsc.Count());

            orderedListAsc.Delete(10);
            Assert.Equal(10, orderedListAsc.Count());

            orderedListAsc.Delete(9);
            Assert.Equal(9, orderedListAsc.Count());
        }
        public void TestDeleteIntegerAsc_5()
        {
            OrderedList <int> ord = new OrderedList <int>(true);

            ord.Add(3);
            ord.Add(2);
            ord.Add(1);

            ord.Delete(1);
            ord.Delete(2);
            ord.Delete(3);
            ord.Delete(4);

            Assert.AreEqual(null, ord.tail);
            Assert.AreEqual(null, ord.tail);
        }
Exemplo n.º 5
0
        public void Delete_from_Empty_Desc_List()
        {
            OrderedList <int> tList = new OrderedList <int>(false);

            tList.Delete(42);

            Assert.IsTrue(tList.Count() == 0);
        }
        public void TestDeleteStringAsc_1()
        {
            OrderedList <string> ord = new OrderedList <string>(true);

            ord.Delete("Brick");

            ord.Delete(null);

            ord.Add("Brick");

            Assert.AreEqual("Brick", ord.head.value);
            Assert.AreEqual("Brick", ord.tail.value);

            ord.Delete("Brick");

            Assert.AreEqual(null, ord.head);
            Assert.AreEqual(null, ord.tail);
        }
        public void TestDeleteIntegerAsc_4()
        {
            OrderedList <int> ord = new OrderedList <int>(true);

            ord.Add(3);
            ord.Add(2);
            ord.Add(1);

            ord.Delete(1);
            ord.Delete(2);
            ord.Delete(3);

            Assert.AreEqual(null, ord.tail);
            Assert.AreEqual(null, ord.tail);

            Node <int> node = ord.Find(1);

            Assert.AreEqual(null, node);
        }
        public void Test_Add_WhenDeletedFromMiddle()
        {
            var list = new OrderedList <int>(true);

            list.Add(1);
            list.Add(2);
            list.Add(3);
            list.Delete(2);

            Assert.AreEqual("[1, 3]", list.ToString());
        }
Exemplo n.º 9
0
        public void TestRemoveDes()
        {
            var stack = new OrderedList <int>(false);

            stack.Add(1);
            stack.Add(3);
            stack.Add(5);
            stack.Add(0);
            stack.Add(2);
            stack.Add(7);
            stack.Add(4);
            stack.Add(4);

            stack.Delete(0);
            stack.Delete(2);
            stack.Delete(4);
            stack.Delete(7);

            Assert.True(stack.ToString().Equals("5 4 3 1"));
        }
Exemplo n.º 10
0
        public void TestCountAsc_1()
        {
            OrderedList <int> ord = new OrderedList <int>(true);

            ord.Add(3);
            ord.Add(2);
            ord.Add(1);

            Assert.AreEqual(3, ord.Count());

            ord.Delete(1);

            Assert.AreEqual(2, ord.Count());

            ord.Delete(2);
            ord.Delete(3);

            Assert.AreEqual(0, ord.Count());

            ord.Delete(1);

            Assert.AreEqual(0, ord.Count());
        }
Exemplo n.º 11
0
        public void TestDeleteStringAsc_3()
        {
            OrderedList <string> ord = new OrderedList <string>(true);

            ord.Add("Fat32");
            ord.Add("Fat32");
            ord.Add("Fat");
            ord.Add("Fat");

            Assert.AreEqual(4, ord.Count());

            ord.Delete("Fat");

            Assert.AreEqual(3, ord.Count());
        }
Exemplo n.º 12
0
        public void Delete_if_Elem_Is_Not_Exists_in_Asc_List()
        {
            OrderedList <int> tList = new OrderedList <int>(true);

            tList.Add(12);
            tList.Add(48);
            tList.Add(35);
            tList.Add(-101);

            tList.Delete(42);
            Node <int> actualFoundValue = tList.Find(42);
            int        expectedSize     = 4;
            int        actualSize       = tList.Count();

            Assert.IsNull(actualFoundValue);
            Assert.AreEqual(expectedSize, actualSize);
        }
Exemplo n.º 13
0
        public void TestDeleteIntegerAsc_3()
        {
            OrderedList <int> ord = new OrderedList <int>(true);

            ord.Add(2);
            ord.Add(1);

            ord.Delete(1);

            Assert.AreEqual(2, ord.tail.value);
            Assert.AreEqual(null, ord.tail.prev);

            Assert.AreEqual(2, ord.head.value);
            Assert.AreEqual(null, ord.head.next);

            Assert.AreEqual(ord.head, ord.tail);
        }
Exemplo n.º 14
0
        public void Delete_if_Elem_Is_Not_Exists_in_Desc_List()
        {
            OrderedList <int> tList = new OrderedList <int>(false);

            tList.Add(122);
            tList.Add(7);
            tList.Add(21);
            tList.Add(7);
            tList.Add(0);

            tList.Delete(42);
            Node <int> actualFoundValue = tList.Find(42);

            int expectedSize = 5;
            int actualSize   = tList.Count();

            Assert.IsNull(actualFoundValue);
            Assert.AreEqual(expectedSize, actualSize);
        }
Exemplo n.º 15
0
        public void Delete_if_Elem_Is_Exists_in_Desc_List()
        {
            OrderedList <int> tList = new OrderedList <int>(false);

            tList.Add(12);
            tList.Add(48);
            tList.Add(35);
            tList.Add(-101);

            tList.Delete(12);

            Node <int> actualFoundValue = tList.Find(12);

            int expectedSize = 3;
            int actualSize   = tList.Count();

            Assert.IsNull(actualFoundValue);
            Assert.AreEqual(expectedSize, actualSize);
            Assert.IsTrue(tList.head.next.next.value == -101);
            Assert.IsTrue(tList.tail.prev.value == 35);
        }
Exemplo n.º 16
0
        public void TestDeleteIntegerAsc_1()
        {
            OrderedList <int> ord = new OrderedList <int>(true);

            ord.Add(4);
            ord.Add(3);
            ord.Add(2);
            ord.Add(1);

            ord.Delete(2);

            Assert.AreEqual(4, ord.tail.value);
            Assert.AreEqual(3, ord.tail.prev.value);
            Assert.AreEqual(1, ord.tail.prev.prev.value);
            Assert.AreEqual(null, ord.tail.prev.prev.prev);

            Assert.AreEqual(1, ord.head.value);
            Assert.AreEqual(3, ord.head.next.value);
            Assert.AreEqual(4, ord.head.next.next.value);
            Assert.AreEqual(null, ord.head.next.next.next);
        }