public void ReverseSingleSublistTest() { Func <ListNode <int>, int, int, ListNode <int> >[] functions = new Func <ListNode <int>, int, int, ListNode <int> >[] { ReverseSingleSublist.BruteForce, ReverseSingleSublist.SinglePass }; for (int i = 0; i < 10; i++) { int[] data = ArrayUtilities.CreateRandomArray(10, 0, 10); for (int start = 1; start <= 10; start++) { for (int end = start; end <= 10; end++) { ListNode <int>[] results = new ListNode <int> [functions.Length]; for (int j = 0; j < results.Length; j++) { ListNode <int> head = LinkedListUtilities.Initialize(data); results[j] = functions[j](head, start, end); Assert.IsTrue(LinkedListUtilities.AreEqual(results[0], results[j])); } } } } }
public void ReverseTest() { Func <ListNode <int>, ListNode <int> >[] functions = new Func <ListNode <int>, ListNode <int> >[] { Reverse.BruteForce, Reverse.Build, Reverse.Traverse }; for (int i = 0; i < 10; i++) { int[] data = ArrayUtilities.CreateRandomArray(10, 0, 15); ListNode <int>[] results = new ListNode <int> [functions.Length]; for (int j = 0; j < functions.Length; j++) { results[j] = functions[j](LinkedListUtilities.Initialize(data)); Assert.IsTrue(LinkedListUtilities.AreEqual(results[0], results[j])); } } }