public static void TestRemoveAll() { var list = new AlgorithmsDataStructures.LinkedList(); list.AddInTail(new AlgorithmsDataStructures.Node(5)); list.RemoveAll(5); if (list.head == null && list.tail == null) { Console.WriteLine("TestRemovedALL part1 PASSED"); } else { Console.WriteLine("TestRemovedALL part1 ERROR"); } list.AddInTail(new AlgorithmsDataStructures.Node(5)); list.AddInTail(new AlgorithmsDataStructures.Node(15)); list.AddInTail(new AlgorithmsDataStructures.Node(25)); list.RemoveAll(5); if (list.head.value == 15 && list.tail.value == 25) { Console.WriteLine("TestRemovedALL part2 PASSED"); } else { Console.WriteLine("TestRemovedALL part2 ERROR"); } list.AddInTail(new AlgorithmsDataStructures.Node(35)); list.RemoveAll(35); if (list.head.value == 15 && list.tail.value == 25) { Console.WriteLine("TestRemovedALL part3 PASSED"); } else { Console.WriteLine("TestRemovedALL part3 ERROR"); } list.RemoveAll(25); if (list.head.value == 15 && list.tail.value == 15) { Console.WriteLine("TestRemovedALL part4 PASSED"); } else { Console.WriteLine("TestRemovedALL part4 ERROR"); } list.AddInTail(new AlgorithmsDataStructures.Node(5)); list.AddInTail(new AlgorithmsDataStructures.Node(15)); list.AddInTail(new AlgorithmsDataStructures.Node(25)); list.RemoveAll(15); if (list.head.value == 5 && list.tail.value == 25) { Console.WriteLine("TestRemovedALL part5 PASSED"); } else { Console.WriteLine("TestRemovedALL part5 ERROR"); } }
public static void TestClear() { var list = new AlgorithmsDataStructures.LinkedList(); list.AddInTail(new AlgorithmsDataStructures.Node(5)); list.AddInTail(new AlgorithmsDataStructures.Node(15)); list.AddInTail(new AlgorithmsDataStructures.Node(25)); list.Clear(); if (list.head == null && list.tail == null) { Console.WriteLine("TestClear PASSED"); } else { Console.WriteLine("TestClear ERROR"); } }
public static void TestFindAll() { List <AlgorithmsDataStructures.Node> nodes1 = new List <AlgorithmsDataStructures.Node>(); var list = new AlgorithmsDataStructures.LinkedList(); list.AddInTail(new AlgorithmsDataStructures.Node(5)); list.AddInTail(new AlgorithmsDataStructures.Node(5)); list.AddInTail(new AlgorithmsDataStructures.Node(15)); list.AddInTail(new AlgorithmsDataStructures.Node(25)); nodes1 = list.FindAll(5); int i = NodeFor(nodes1, 0); if (i == 2) { Console.WriteLine("TestFindAll part1 PASSED"); } else { Console.WriteLine("TestFindAll part1 ERROR"); } nodes1.Clear(); nodes1 = list.FindAll(51); i = NodeFor(nodes1, 0); if (i == 0) { Console.WriteLine("TestFindAll part2 PASSED"); } else { Console.WriteLine("TestFindAll part2 ERROR"); } list.Clear(); nodes1.Clear(); nodes1 = list.FindAll(1); i = NodeFor(nodes1, 0); if (i == 0) { Console.WriteLine("TestFindAll part3 PASSED"); } else { Console.WriteLine("TestFindAll part3 ERROR"); } }
public static void TestCount() { var list = new AlgorithmsDataStructures.LinkedList(); for (int i = 0; i < 100; i++) { list.AddInTail(new AlgorithmsDataStructures.Node(i)); } if (list.Count() == 100) { Console.WriteLine("TestCount PASSED"); } else { Console.WriteLine("TestCount ERROR"); } }