public void FindsPaths() { var inputOne = TreeNode.BuildTreeOne(); var pathsOne = PathSum.GetPaths(inputOne, 9); Assert.Equal(new List <List <int> > { new List <int> { 5, 3, 1 } }, pathsOne); var inputTwo = TreeNode.BuildTreeThree(); var pathsTwo = PathSum.GetPaths(inputTwo, 17); Assert.Equal(new List <List <int> > { new List <int> { 3, 5, 2, 7 } }, pathsTwo); var inputThree = TreeNode.BuildTreeFour(); var pathsThree = PathSum.GetPaths(inputThree, 14); var multiplePaths = new List <List <int> > { new List <int> { 3, 5, 6 }, new List <int> { 3, 5, 2, 4 }, new List <int> { 3, 1, 8, 2 } }; Assert.Equal(multiplePaths, pathsThree); }
public void DoesNotFindNotExistingPaths() { var inputOne = TreeNode.BuildTreeTwo(); var pathsOne = PathSum.GetPaths(inputOne, 9); Assert.Empty(pathsOne); var inputTwo = TreeNode.BuildTreeThree(); var pathsTwo = PathSum.GetPaths(inputTwo, 9); Assert.Empty(pathsTwo); }