public void testPopBack() { DEQueue <string> b = new DEQueue <string>(); Assert.AreEqual(null, b.popBack()); b.pushBack("abc"); b.pushBack("cba"); Assert.AreEqual("cba", b.popBack()); 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 PopBackAloneTest() { DEQueue <string> deq = new DEQueue <string>(); deq.popBack(); Assert.IsTrue(deq.Size == 0); Assert.IsNull(deq.Head); Assert.IsNull(deq.Tail); }
public void PopBackTest() { 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.popBack(); Assert.IsTrue(deq.Size == 2); Assert.AreEqual("a", deq.Head.Data); Assert.AreEqual("b", deq.Tail.Data); deq.popBack(); Assert.IsTrue(deq.Size == 1); Assert.AreEqual("a", deq.Head.Data); Assert.AreEqual("a", deq.Tail.Data); }
public void popBackTest_KostyaAndMark_KostyaReturn() { // arrange DEQueue <string> queue = new DEQueue <string>(); string expected = "Kostya"; // act queue.pushBack("Kostya"); queue.pushBack("Mark"); queue.pushFront("Kate"); queue.popBack(); // assert Assert.AreEqual(expected, queue.back); }
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); }
public void DeqTest2() { DEQueue <int> Deq = new DEQueue <int>(); Deq.pushFront(1); Deq.pushFront(2); Deq.pushFront(3); Deq.popBack(); int[] expected = { 3, 2 }; 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(); }