public void PathSumTestCase3() { var tree = new MyBinaryTree(1); tree.Left = new MyBinaryTree(2); PathSum.HasPathSum(tree, 1).Should().Be(false); }
public void PathSumTestCase1() { var tree = new MyBinaryTree(5); tree.Left = new MyBinaryTree(4); tree.Left.Left = new MyBinaryTree(11); tree.Left.Left.Left = new MyBinaryTree(7); tree.Left.Left.Right = new MyBinaryTree(2); tree.Right = new MyBinaryTree(8); tree.Right.Left = new MyBinaryTree(4); tree.Right.Left.Left = new MyBinaryTree(1); tree.Right.Right = new MyBinaryTree(13); PathSum.HasPathSum(tree, 22).Should().Be(true); }
public void TestMethod2() { // Arrange PathSum question = new PathSum(); TreeNode root = new TreeNode(-2); root.right = new TreeNode(-3); bool expected = true; // Act bool actual = question.HasPathSum(root, -5); // Assert Assert.AreEqual(expected, actual); }
public void TestPath1() { var root = new TreeNode(5); root.Left = new TreeNode(4); root.Right = new TreeNode(8); root.Left.Left = new TreeNode(11); root.Left.Left.Left = new TreeNode(7); root.Left.Left.Right = new TreeNode(2); root.Right.Left = new TreeNode(13); root.Right.Right = new TreeNode(4); root.Right.Right.Right = new TreeNode(1); var r = PathSum.HasPathSum(root, 22); Assert.AreEqual(r, true); r = PathSum.HasPathSum(root, 13); Assert.AreEqual(r, false); }
public void TestMethod1() { // Arrange PathSum question = new PathSum(); TreeNode root = new TreeNode(5); root.left = new TreeNode(4); root.left.left = new TreeNode(11); root.left.left.left = new TreeNode(7); root.left.left.right = new TreeNode(2); root.right = new TreeNode(8); root.right.left = new TreeNode(13); root.right.right = new TreeNode(4); root.right.right.right = new TreeNode(1); bool expected = true; // Act bool actual = question.HasPathSum(root, 22); // Assert Assert.AreEqual(expected, actual); }