private static void Validate <T>(bool expected, Node <T> head) where T : IEquatable <T> { var result = Question_2_6.IsPalindrome(head); Assert.AreEqual(expected, result); result = Question_2_6.IsPalindromeRecursive(head); Assert.AreEqual(expected, result); }
public void IsPalindromeRecursiveTest_ReturnFalse() { var testList = new LinkedList(new int[] { 1, 2, 3, 2, 5 }); bool result = Question_2_6.IsPalindromeRecursive(testList); Assert.IsFalse(result, $"List {testList} is palindrome."); testList = new LinkedList(new int[] { 1, 2, 3, 3, 2, 6 }); result = Question_2_6.IsPalindromeRecursive(testList); Assert.IsFalse(result, $"List {testList} is palindrome."); }
public void IsPalindromeRecursiveTest_ReturnTrue() { var testList = new LinkedList(new int[] { 0, 1, 2, 3, 2, 1, 0 }); bool result = Question_2_6.IsPalindromeRecursive(testList); Assert.IsTrue(result, $"List {testList} is not palindrome."); testList = new LinkedList(new int[] { 0, 1, 2, 3, 3, 2, 1, 0 }); result = Question_2_6.IsPalindromeRecursive(testList); Assert.IsTrue(result, $"List {testList} is not palindrome."); }