Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit86c505b

Browse files
add test for 100
1 parent04eaece commit86c505b

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp