|
| 1 | +packagecom.fishercoder; |
| 2 | + |
| 3 | +importcom.fishercoder.common.classes.TreeNode; |
| 4 | +importcom.fishercoder.common.utils.TreeUtils; |
| 5 | +importcom.fishercoder.solutions._100; |
| 6 | +importorg.junit.BeforeClass; |
| 7 | +importorg.junit.Test; |
| 8 | + |
| 9 | +importjava.util.Arrays; |
| 10 | + |
| 11 | +importstaticorg.junit.Assert.assertEquals; |
| 12 | + |
| 13 | +publicclass_100Test { |
| 14 | +privatestatic_100.Solution1solution1; |
| 15 | +privatestaticTreeNodep; |
| 16 | +privatestaticTreeNodeq; |
| 17 | + |
| 18 | +@BeforeClass |
| 19 | +publicstaticvoidsetup() { |
| 20 | +solution1 =new_100.Solution1(); |
| 21 | + } |
| 22 | + |
| 23 | +@Test |
| 24 | +publicvoidtest1() { |
| 25 | +p =TreeUtils.constructBinaryTree(Arrays.asList(1,2,3)); |
| 26 | +TreeUtils.printBinaryTree(p); |
| 27 | +q =TreeUtils.constructBinaryTree(Arrays.asList(1,2,3)); |
| 28 | +TreeUtils.printBinaryTree(p); |
| 29 | +assertEquals(true,solution1.isSameTree(p,q)); |
| 30 | + } |
| 31 | + |
| 32 | +@Test |
| 33 | +publicvoidtest2() { |
| 34 | +p =TreeUtils.constructBinaryTree(Arrays.asList(1,2)); |
| 35 | +TreeUtils.printBinaryTree(p); |
| 36 | +q =TreeUtils.constructBinaryTree(Arrays.asList(1,null,2)); |
| 37 | +TreeUtils.printBinaryTree(p); |
| 38 | +assertEquals(false,solution1.isSameTree(p,q)); |
| 39 | + } |
| 40 | + |
| 41 | +@Test |
| 42 | +publicvoidtest3() { |
| 43 | +p =TreeUtils.constructBinaryTree(Arrays.asList(1,2,1)); |
| 44 | +TreeUtils.printBinaryTree(p); |
| 45 | +q =TreeUtils.constructBinaryTree(Arrays.asList(1,1,2)); |
| 46 | +TreeUtils.printBinaryTree(p); |
| 47 | +assertEquals(false,solution1.isSameTree(p,q)); |
| 48 | + } |
| 49 | +} |