Example #1
0
        //this method test RemoveElement() method
        public void PushBack12345_1245returned()
        {
            string expected        = "1245";
            int    expected_size   = 4;
            string list_buffer     = "";
            int    expected_return = 3;
            int    retrn;

            simple_ds.Structures.LinkedList <int> list = new simple_ds.Structures.LinkedList <int>();

            for (var number = 1; number <= 5; ++number)
            {
                list.PushBack(number);
            }

            retrn = list.RemoveElement(3);

            while (!list.isEmpty())
            {
                list_buffer += list.RemoveHead();
            }

            Assert.AreEqual(expected, list_buffer);

            Assert.AreEqual(expected_return, retrn);
        }
Example #2
0
        //this method test isEmpty() method
        public void PushStart12345_falsereturned()
        {
            bool expected = false;
            bool list_buffer;

            simple_ds.Structures.LinkedList <int> list = new simple_ds.Structures.LinkedList <int>();

            for (var number = 1; number <= 5; ++number)
            {
                list.PushStart(number);
            }

            list_buffer = list.isEmpty();

            Assert.AreEqual(expected, list_buffer);
        }
Example #3
0
        //this method test Copy() method
        public void PushBack12345_54321returned()
        {
            string expected    = "54321";
            string list_buffer = "";

            simple_ds.Structures.LinkedList <int> list = new simple_ds.Structures.LinkedList <int>();

            for (var number = 1; number <= 5; ++number)
            {
                list.PushBack(number);
            }

            list.Reverse();

            while (!list.isEmpty())
            {
                list_buffer += list.RemoveHead();
            }

            Assert.AreEqual(expected, list_buffer);
        }
Example #4
0
        //this method test Copy() method
        public void PushBack12345_12345returned()
        {
            string expected    = "12345";
            string list_buffer = "";

            simple_ds.Structures.LinkedList <int> list        = new simple_ds.Structures.LinkedList <int>();
            simple_ds.Structures.LinkedList <int> copied_list = new simple_ds.Structures.LinkedList <int>();

            for (var number = 1; number <= 5; ++number)
            {
                list.PushBack(number);
            }

            copied_list = list.Copy();

            while (!copied_list.isEmpty())
            {
                list_buffer += copied_list.RemoveHead();
            }

            Assert.AreEqual(expected, list_buffer);
        }
Example #5
0
        //this method test Sort() method
        public void PushBack15324_12345returned()
        {
            string expected    = "12345";
            string list_buffer = "";

            simple_ds.Structures.LinkedList <int> list = new simple_ds.Structures.LinkedList <int>();

            list.PushBack(1);
            list.PushBack(5);
            list.PushBack(3);
            list.PushBack(2);
            list.PushBack(4);

            list.Sort();

            while (!list.isEmpty())
            {
                list_buffer += list.RemoveHead();
            }

            Assert.AreEqual(expected, list_buffer);
        }