コード例 #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);
        }
コード例 #2
0
        //this method test RemoveHead() method
        public void PushBack12345_1returned()
        {
            int expected      = 1;
            int expected_size = 4;
            int 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_buffer = list.RemoveHead();

            Assert.AreEqual(expected, list_buffer);
            Assert.AreEqual(expected_size, list.Size());
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }