private static void Test_Binary_Search_Returns_False(BSTNode <int> root, int[] values) { var preOrder = BinaryTreeRecursiveWalker.TraversalMode.PreOrder; var inOrder = BinaryTreeRecursiveWalker.TraversalMode.InOrder; var postOrder = BinaryTreeRecursiveWalker.TraversalMode.PostOrder; foreach (var value in values) { Debug.Assert( false == BinaryTreeRecursiveWalker.BinarySearch(root, value, preOrder), "Wrong boolean returned, expected False from Contains"); } foreach (var value in values) { Debug.Assert( false == BinaryTreeRecursiveWalker.BinarySearch(root, value, inOrder), "Wrong boolean returned, expected False from Contains"); } foreach (var value in values) { Debug.Assert( false == BinaryTreeRecursiveWalker.BinarySearch(root, value, postOrder), "Wrong boolean returned, expected False from Contains"); } }
private static void TestBinarySearchReturnsFalse() { var values = new int[] { 0, 20, 30, 40, 50 }; var preOrder = BinaryTreeRecursiveWalker.TraversalMode.PreOrder; var inOrder = BinaryTreeRecursiveWalker.TraversalMode.InOrder; var postOrder = BinaryTreeRecursiveWalker.TraversalMode.PostOrder; foreach (var value in values) { Assert.False(BinaryTreeRecursiveWalker.BinarySearch(_root, value, preOrder), "Wrong boolean returned, expected False from Contains"); } foreach (var value in values) { Assert.False(BinaryTreeRecursiveWalker.BinarySearch(_root, value, inOrder), "Wrong boolean returned, expected False from Contains"); } foreach (var value in values) { Assert.False(BinaryTreeRecursiveWalker.BinarySearch(_root, value, postOrder), "Wrong boolean returned, expected False from Contains"); } }
private static void TestBinarySearchReturnsTrue() { var values = new[] { 10, 5, 3, 7, 15, 13, 17 }; var preOrder = BinaryTreeRecursiveWalker.TraversalMode.PreOrder; var inOrder = BinaryTreeRecursiveWalker.TraversalMode.InOrder; var postOrder = BinaryTreeRecursiveWalker.TraversalMode.PostOrder; foreach (var value in values) { Assert.True(BinaryTreeRecursiveWalker.BinarySearch(Root, value, preOrder), "Wrong boolean returned, expected True from Contains"); } foreach (var value in values) { Assert.True(BinaryTreeRecursiveWalker.BinarySearch(Root, value, inOrder), "Wrong boolean returned, expected True from Contains"); } foreach (var value in values) { Assert.True(BinaryTreeRecursiveWalker.BinarySearch(Root, value, postOrder), "Wrong boolean returned, expected True from Contains"); } }