import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.junit.Test;
public class PathFindOneTest {
@Test
public void basicTest() {
int[] values = {10, -5, -20};
System.out.println("Layer order");
BTree root = PathFindOne.buildTree(values);
BTreePrinter.printNode(root);
Set<List<BTree>> paths = new HashSet<>();
List<BTree> path = new ArrayList<>();
int total = -15;
PathFindOne.pathFind(root, paths, path, total);
System.out.println("paths with sum = " + total);
System.out.println(paths);
int[] values2 = {10, -5, 20};
System.out.println("Layer order");
root = PathFindOne.buildTree(values2);
BTreePrinter.printNode(root);
paths = new HashSet<>();
path = new ArrayList<>();
total = 5;
PathFindOne.pathFind(root, paths, path, total);
System.out.println("paths with sum = " + total);
System.out.println(paths);
int[] values3 = {10, 9, 14, -5, -20, 3, -15, 7, 26, -9};
System.out.println("Layer order");
root = PathFindOne.buildTree(values3);
BTreePrinter.printNode(root);
paths = new HashSet<>();
path = new ArrayList<>();
total = 5;
PathFindOne.pathFind(root, paths, path, total);
System.out.println("paths with sum = " + total);
System.out.println(paths);
int[] values4 = {10};
System.out.println("Layer order");
root = PathFindOne.buildTree(values4);
BTreePrinter.printNode(root);
paths = new HashSet<>();
path = new ArrayList<>();
total = 10;
PathFindOne.pathFind(root, paths, path, total);
System.out.println("paths with sum = " + total);
System.out.println(paths);
int[] values5 = {};
System.out.println("Layer order");
root = PathFindOne.buildTree(values5);
BTreePrinter.printNode(root);
paths = new HashSet<>();
path = new ArrayList<>();
total = 0;
PathFindOne.pathFind(root, paths, path, total);
System.out.println("paths with sum = " + total);
System.out.println(paths);
int[] values6 = {-1};
System.out.println("Layer order");
root = PathFindOne.buildTree(values6);
BTreePrinter.printNode(root);
paths = new HashSet<>();
path = new ArrayList<>();
total = -1;
PathFindOne.pathFind(root, paths, path, total);
System.out.println("paths with sum = " + total);
System.out.println(paths);;
int[] values7 = {-1, -8, -4};
System.out.println("Layer order");
root = PathFindOne.buildTree(values7);
BTreePrinter.printNode(root);
paths = new HashSet<>();
path = new ArrayList<>();
total = -9;
PathFindOne.pathFind(root, paths, path, total);
System.out.println("paths with sum = " + total);
System.out.println(paths);
paths = new HashSet<>();
path = new ArrayList<>();
total = -13;
PathFindOne.pathFind(root, paths, path, total);
System.out.println("paths with sum = " + total);
System.out.println(paths);
int[] values8 = {16, -85, 26, -9, 52, -33, 0, -21, 93};
System.out.println("Layer order");
root = PathFindOne.buildTree(values8);
BTreePrinter.printNode(root);
paths = new HashSet<>();
path = new ArrayList<>();
total = 5;
PathFindOne.pathFind(root, paths, path, total);
System.out.println("paths with sum = " + total);
System.out.println(paths);
int[] values9 = {16, -85, 26, -9, 52, -33, 0, -21, 93};
System.out.println("Layer order");
root = PathFindOne.buildTree(values9);
BTreePrinter.printNode(root);
paths = new HashSet<>();
path = new ArrayList<>();
total = -132;
PathFindOne.pathFind(root, paths, path, total);
System.out.println("paths with sum = " + total);
System.out.println(paths);
int[] values10 = {16, -85, 26, -9, 52, -33, 0, -21, 93};
System.out.println("Layer order");
root = PathFindOne.buildTree(values10);
BTreePrinter.printNode(root);
paths = new HashSet<>();
path = new ArrayList<>();
total = -78;
PathFindOne.pathFind(root, paths, path, total);
System.out.println("paths with sum = " + total);
System.out.println(paths);
}
@Test
public void testMuliplePaths() {
int[] values10 = {10, 5, 9, 14, -5, -20, 3, -15, -9};
System.out.println("Layer order");
BTree root = PathFindOne.buildTree(values10);
BTreePrinter.printNode(root);
Set<List<BTree>> paths = new HashSet<>();
List<BTree> path = new ArrayList<>();
int total = 24;
PathFindOne.pathFind(root, paths, path, total);
System.out.println("paths with sum = " + total);
System.out.println(paths);
paths = new HashSet<>();
path = new ArrayList<>();
total = 13;
PathFindOne.pathFind(root, paths, path, total);
System.out.println("paths with sum = " + total);
System.out.println(paths);
}
}