/// <summary> /// Test removing an item from an empty array /// </summary> static void TestRemoveEmptyDynamicArray() { UnorderedIntDynamicArray array = new UnorderedIntDynamicArray(); System.Console.Write("TestRemoveEmptyDynamicArray: "); if (!array.Remove(42)) { System.Console.WriteLine("Passed"); } else { System.Console.WriteLine("FAILED!!! Expected: false Actual: true"); } }
/// <summary> /// Test finding the index of an item in an empty array /// </summary> static void TestIndexOfEmptyDynamicArray() { UnorderedIntDynamicArray array = new UnorderedIntDynamicArray(); System.Console.Write("TestIndexOfEmptyDynamicArray: "); int actualIndex = array.IndexOf(42); if (actualIndex == -1) { System.Console.WriteLine("Passed"); } else { System.Console.WriteLine("FAILED!!! Expected: -1 Actual: " + actualIndex); } }
/// <summary> /// Test removing an item in the interior of the array /// </summary> static void TestRemoveItemInteriorOfDynamicArray() { UnorderedIntDynamicArray array = new UnorderedIntDynamicArray(); array.Add(42); array.Add(41); array.Add(40); System.Console.Write("TestRemoveItemInteriorOfDynamicArray: "); bool removed = array.Remove(41); String arrayString = array.ToString(); if (removed && arrayString.Equals("42,40") && array.Count == 2) { System.Console.WriteLine("Passed"); } else { System.Console.WriteLine("FAILED!!! Expected: 42,40 Actual: " + arrayString); } }