public void testPopFront() { DEQueue <string> b = new DEQueue <string>(); Assert.AreEqual(null, b.popFront()); b.pushBack("abc"); b.pushBack("cba"); Assert.AreEqual("abc", b.popFront()); Assert.IsTrue(b.Count == 1); }
public void TestMethod4()//test_popfront_popback { DEQueue <string> qwsda = new DEQueue <string>(); qwsda.pushBack("a"); qwsda.pushBack("b"); qwsda.pushBack("c"); qwsda.pushBack("d"); string a = qwsda.popFront() + qwsda.popBack() + qwsda.popFront() + qwsda.popBack(); Assert.AreEqual(a, "adbc"); }
public void PopFrontAloneTest() { DEQueue <string> deq = new DEQueue <string>(); deq.popFront(); Assert.IsTrue(deq.Size == 0); Assert.IsNull(deq.Head); Assert.IsNull(deq.Tail); }
public void PopFrontTest() { DEQueue <string> deq = new DEQueue <string>(); deq.pushBack("a"); deq.pushBack("b"); deq.pushBack("c"); Assert.IsTrue(deq.Size == 3); Assert.AreEqual("a", deq.Head.Data); Assert.AreEqual("c", deq.Tail.Data); deq.popFront(); Assert.IsTrue(deq.Size == 2); Assert.AreEqual("b", deq.Head.Data); Assert.AreEqual("c", deq.Tail.Data); deq.popFront(); Assert.IsTrue(deq.Size == 1); Assert.AreEqual("c", deq.Head.Data); Assert.AreEqual("c", deq.Tail.Data); }
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); }
public void popFrontTest_LuffyAndZoroAndSanji_ReturnedLuffy() { // arrange DEQueue <string> queue = new DEQueue <string>(); string expected = "Luffy"; // act queue.pushFront("Luffy"); queue.pushBack("Zoro"); queue.pushFront("Sanji"); queue.popFront(); // assert Assert.AreEqual(expected, queue.front); }
public void DeqTest5() { DEQueue <int> Deq = new DEQueue <int>(); Deq.pushFront(1); Deq.pushFront(2); Deq.pushFront(3); Deq.popFront(); int[] expected = { 2, 1 }; int i = 0; foreach (int s in Deq) { Assert.AreEqual(expected[i], s); i++; } }
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(); }
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(); }