/// <summary> /// Test adding an item to an empty array /// </summary> static void TestAddEmptyDynamicArray() { UnorderedIntDynamicArray array = new UnorderedIntDynamicArray(); array.Add(42); System.Console.Write("TestAddEmptyDynamicArray: "); String arrayString = array.ToString(); if (arrayString.Equals("42") && array.Count == 1) { System.Console.WriteLine("Passed"); } else { System.Console.WriteLine("FAILED!!! Expected: 42 Actual: " + arrayString); } }
/// <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); } }
/// <summary> /// Test adding an item to an array that needs to be expanded /// </summary> static void TestAddExpandDynamicArray() { UnorderedIntDynamicArray array = new UnorderedIntDynamicArray(); array.Add(42); array.Add(41); array.Add(40); array.Add(39); array.Add(38); array.Add(37); System.Console.Write("TestAddExpandedDynamicArray: "); String arrayString = array.ToString(); if (arrayString.Equals("42,41,40,39,38,37") && array.Count == 6) { System.Console.WriteLine("Passed"); } else { System.Console.WriteLine("FAILED!!! Expected: 42,41,40,39,38,37 Actual: " + arrayString); } }