Exemplo n.º 1
0
        private void ClearTest(params Node[] nodes)
        {
            LinkedList2 list = GetLinkedList(nodes);

            list.Clear();

            Assert.Null(list.head);
            Assert.Null(list.tail);
        }
Exemplo n.º 2
0
        public void TestMethod1()
        {
            LinkedList2 list = new LinkedList2();

            list.AddInTail(new Node(10));
            list.AddInTail(new Node(11));
            list.AddInTail(new Node(12));
            list.Clear();
            Assert.IsTrue(list.head == null && list.tail == null);
        }
Exemplo n.º 3
0
        public static void TestClear()
        {
            var testList = new LinkedList2();

            testList.AddInTail(new Node(1));
            testList.AddInTail(new Node(2));
            testList.AddInTail(new Node(1));
            testList.AddInTail(new Node(3));
            testList.AddInTail(new Node(1));
            testList.AddInTail(new Node(4));
            testList.Clear();
            Assert.AreEqual(0, testList.Count(), "Test TestClear failed. List count not equal 0");
        }
Exemplo n.º 4
0
        public void Test_Clear_WhenNonEmpty()
        {
            var list  = new LinkedList2();
            var node1 = new Node(1);

            list.AddInTail(node1);
            list.Clear();
            var count = list.Count();

            Assert.AreEqual(null, list.head);
            Assert.AreEqual(null, list.tail);
            Assert.AreEqual(0, count);
        }
        public static void Main()
        {
            var test = new LinkedList2<string>();

            test.AddFirst("First string");
            test.AddLast("Second string");
            test.AddFirst("Should be before first");
            test.AddLast("Should be after last");

            foreach (var item in test)
            {
                Console.WriteLine(item);
            }

            test.Clear();
            foreach (var item in test)
            {
                Console.WriteLine(item);
            }
        }
Exemplo n.º 6
0
        static void TestClear()
        {
            Console.WriteLine("clear test");

            var list = new LinkedList2();

            list.AddInTail(new Node(20));
            list.AddInTail(new Node(24));
            list.AddInTail(new Node(10));
            list.AddInTail(new Node(15));
            list.AddInTail(new Node(77));
            list.AddInTail(new Node(24));

            Console.WriteLine("count before clear = " + list.Count());
            Console.WriteLine("head before clear = " + list.head.value);
            Console.WriteLine("tail before clear = " + list.tail.value);
            list.Clear();
            Console.WriteLine("count after clear = " + list.Count());
            Console.WriteLine("head after clear = " + (list.head == null ? "null" : list.head.value.ToString()));
            Console.WriteLine("tail after clear = " + (list.head == null ? "null" : list.tail.value.ToString()));

            Console.WriteLine(new string('=', 30));
        }