예제 #1
0
파일: Test.cs 프로젝트: UserTundra/DEQueue
        public void FrontManyTest()
        {
            DEQueue <string> deq = new DEQueue <string>();

            deq.pushFront("a");
            deq.pushBack("b");
            deq.pushFront("c");
            Assert.AreEqual("c", deq.front().Data);
        }
예제 #2
0
파일: Test.cs 프로젝트: UserTundra/DEQueue
        public void PushFrontManyTest()
        {
            DEQueue <string> deq = new DEQueue <string>();

            deq.pushFront("a");
            deq.pushFront("b");
            deq.pushFront("c");
            Assert.IsTrue(deq.Size == 3);
            Assert.IsTrue(deq.Head.Data == "c");
            Assert.IsTrue(deq.Tail.Data == "a");
        }
예제 #3
0
        public void DeqTest3()
        {
            DEQueue <int> Deq = new DEQueue <int>();

            Deq.pushFront(1);
            Deq.pushFront(2);
            Deq.pushFront(3);
            int res      = Deq.front;
            int expected = 3;

            Assert.AreEqual(expected, res);
        }
예제 #4
0
        public void pushFront_Test2()
        {
            string           expected = "q";
            DEQueue <String> q        = new DEQueue <string>(); // Создание очереди для хранения строк

            q.pushFront("5");                                   // 5
            q.pushFront("b");                                   // b 5
            q.pushFront("b");                                   // b b 5
            q.pushFront("q");                                   // q b b 5
            string s = q.back();

            Assert.AreEqual(expected, s);
        }
예제 #5
0
        public void sizeTest_LuffyAndZoroAndSanji_Returned3()
        {
            // arrange
            DEQueue <string> queue = new DEQueue <string>();
            int expected           = 3;

            // act
            queue.pushFront("Luffy");
            queue.pushBack("Zoro");
            queue.pushFront("Sanji");

            // assert
            Assert.AreEqual(expected, queue.size);
        }
예제 #6
0
        public void Main_Test2()
        {
            string           expected = "a";
            DEQueue <String> q        = new DEQueue <String>(); // Создание очереди для хранения строк

            q.pushFront("a");                                   // очередь: a
            q.pushFront("b");                                   // очередь: b a
            q.pushBack("c");                                    // очередь: b a c
            String s = q.front();                               // s = “b”

            s = q.pop();                                        // s = “c”;    очередь:  b a

            Assert.AreEqual(expected, s);
        }
예제 #7
0
        public void pushBackTest_MarkAndAlisa_AlisaReturn()
        {
            // arrange
            DEQueue <string> queue    = new DEQueue <string>();
            string           expected = "Alisa";

            // act
            queue.pushFront("Mark");
            queue.pushFront("Azat");
            queue.pushBack("Alisa");

            // assert
            Assert.AreEqual(expected, queue.back);
        }
예제 #8
0
파일: Test.cs 프로젝트: UserTundra/DEQueue
        public void ToArrayStringTest()
        {
            string[] output = { "c", "a", "b" };

            DEQueue <string> deq = new DEQueue <string>();

            deq.pushFront("a");
            deq.pushBack("b");
            deq.pushFront("c");
            for (int i = 0; i < 3; i++)
            {
                Assert.AreEqual(output[i], deq.toArray()[i]);
            }
        }
예제 #9
0
        public void popFrontTest_KostyaAndMark_MarkReturn()
        {
            // arrange
            DEQueue <string> queue    = new DEQueue <string>();
            string           expected = "Mark";

            // act
            queue.pushBack("Kostya");
            queue.pushFront("Mark");
            queue.pushFront("Kate");
            queue.popFront();

            // assert
            Assert.AreEqual(expected, queue.front);
        }
예제 #10
0
        public void popBackTest_LuffyAndZoroAndSanji_ReturnedLuffy()
        {
            // arrange
            DEQueue <string> queue    = new DEQueue <string>();
            string           expected = "Luffy";

            // act
            queue.pushFront("Luffy");
            queue.pushBack("Zoro");
            queue.pushFront("Sanji");
            queue.popBack();

            // assert
            Assert.AreEqual(expected, queue.back);
        }
예제 #11
0
파일: Test.cs 프로젝트: UserTundra/DEQueue
        public void ClearTest()
        {
            DEQueue <string> deq = new DEQueue <string>();

            deq.pushFront("a");
            deq.pushBack("b");
            deq.pushFront("c");
            Assert.IsTrue(deq.Size == 3);
            Assert.AreEqual("c", deq.Head.Data);
            Assert.AreEqual("b", deq.Tail.Data);

            deq.clear();
            Assert.IsTrue(deq.Size == 0);
            Assert.IsNull(deq.Head);
            Assert.IsNull(deq.Tail);
        }
예제 #12
0
        public void DeqTest1()
        {
            DEQueue <int> Deq = new DEQueue <int>();

            Deq.pushFront(1);
            Deq.pushFront(2);
            Deq.pushFront(3);
            int[] expected = { 3, 2, 1 };
            int   i        = 0;

            foreach (int s in Deq)
            {
                Assert.AreEqual(expected[i], s);
                i++;
            }
        }
예제 #13
0
        public void clearTest_LuffyAndZoroAndSanji_ReturnedNami()
        {
            // arrange
            DEQueue <string> queue    = new DEQueue <string>();
            string           expected = "Nami";

            // act
            queue.pushFront("Luffy");
            queue.pushBack("Zoro");
            queue.pushFront("Sanji");
            queue.Clear();

            queue.pushBack("Nami");
            queue.pushBack("Usopp");
            queue.pushBack("Chopper");

            // assert
            Assert.AreEqual(expected, queue.front);
        }
예제 #14
0
파일: Test.cs 프로젝트: UserTundra/DEQueue
        public void PushFrontTest()
        {
            DEQueue <string> deq = new DEQueue <string>();

            deq.pushFront("a");
            Assert.IsTrue(deq.Size == 1);

            foreach (var item in deq)
            {
                Assert.AreEqual("a", item);
            }
        }
예제 #15
0
파일: Test.cs 프로젝트: UserTundra/DEQueue
        public void ToArrayIntTest()
        {
            int[]         output = { 1, 2, 3, 4, 5 };
            DEQueue <int> deq    = new DEQueue <int>();

            deq.pushFront(1);
            deq.pushBack(2);
            deq.pushBack(3);
            deq.pushBack(4);
            deq.pushBack(5);
            for (int i = 0; i < 5; i++)
            {
                Assert.AreEqual(output[i], deq.toArray()[i]);
            }
        }
예제 #16
0
        private static void Main(string[] args)
        {
            DEQueue <string> queue = new DEQueue <string>();

            // добавление элементов

            Console.WriteLine("-------Добавление элементов--------");

            queue.pushBack("Bob");
            queue.pushBack("Bill");
            queue.pushBack("Tom");
            queue.pushFront("Kate");
            foreach (var item in queue)
            {
                Console.WriteLine(item);
            }

            Console.WriteLine();

            Console.WriteLine("-------Удаление из начала--------");

            Console.WriteLine(queue.popFront());

            Console.WriteLine();

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

            Console.WriteLine();

            Console.WriteLine("-------Удаление из конца--------");

            Console.WriteLine(queue.popBack());

            Console.WriteLine();

            Console.WriteLine("-------Количество элементов в очереди--------");

            Console.WriteLine(queue.size);

            Console.WriteLine();

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

            Console.WriteLine("-------Очищение очереди--------");

            queue.Clear();

            Console.WriteLine();

            Console.WriteLine("----Добавление элементов-----");

            queue.pushBack("Bob");
            queue.pushBack("Bill");
            queue.pushBack("Tom");
            queue.pushFront("Kate");

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

            Console.WriteLine("-------Преобразование в список--------");

            foreach (var x in queue.convertToArray())
            {
                Console.WriteLine(x);
            }

            string[] ss = (string[])queue.convertToArray().Clone();

            Console.WriteLine("-------Копия списка--------");

            foreach (var x in ss.ToArray())
            {
                Console.WriteLine(x);
            }

            Console.WriteLine();

            Console.WriteLine("-------True потому что преобразовали очередь в список--------");
            if (ss.ToArray().GetType() == queue.convertToArray().GetType())
            {
                Console.WriteLine("True");
            }

            Console.Read();
        }
예제 #17
0
        private static void Main(string[] args)
        {
            DEQueue <string> queue = new DEQueue <string>();


            Console.WriteLine("---Добавление элементов---");
            queue.pushFront("Mark");
            queue.pushFront("Alisa");
            queue.pushBack("Kate");
            queue.pushBack("Ed");
            queue.pushBack("Kostya");
            queue.pushFront("Ilyas");
            foreach (var item in queue)
            {
                Console.WriteLine(item);
            }

            Console.WriteLine("---Удаление с начала---");

            Console.WriteLine(queue.popFront());

            Console.WriteLine("---Вывод данных---");

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

            Console.WriteLine("---Удаление с конца---");
            Console.WriteLine(queue.popBack());

            Console.WriteLine("---Вывод данных---");

            foreach (var item in queue)
            {
                Console.WriteLine(item);
            }
            Console.WriteLine("---Очистка данных---");
            queue.Clear();

            queue.pushFront("Mark");
            queue.pushFront("Alisa");
            queue.pushBack("Kate");
            queue.pushBack("Ed");
            queue.pushBack("Kostya");
            queue.pushFront("Ilyas");

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

            Console.WriteLine("---ЛИСТ---");

            foreach (var x in queue.convertToArray())
            {
                Console.WriteLine(x);
            }


            string[] ss = (string[])queue.convertToArray().Clone();

            Console.WriteLine("---ЛИСТ КОПИЯ---");

            foreach (var x in ss.ToArray())
            {
                Console.WriteLine(x);
            }


            Console.WriteLine("---Проверка Типов---");

            if (ss.ToArray().GetType() == queue.convertToArray().GetType())
            {
                Console.WriteLine("True");
            }


            Console.Read();
        }