Skip to content

Commit dd52268

Browse files
add a test for 270
1 parent d185eca commit dd52268

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package com.fishercoder;
2+
3+
import com.fishercoder.common.classes.TreeNode;
4+
import com.fishercoder.common.utils.TreeUtils;
5+
import com.fishercoder.solutions._270;
6+
import org.junit.BeforeClass;
7+
import org.junit.Test;
8+
9+
import java.util.Arrays;
10+
11+
import static junit.framework.Assert.assertEquals;
12+
13+
public class _270Test {
14+
private static _270.Solution1 solution1;
15+
private static int expected;
16+
private static TreeNode root;
17+
private static double target;
18+
19+
@BeforeClass
20+
public static void setup() {
21+
solution1 = new _270.Solution1();
22+
}
23+
24+
@Test
25+
public void test1() {
26+
root = TreeUtils.constructBinaryTree(Arrays.asList(4, 2, 5, 1, 3));
27+
expected = 4;
28+
target = 3.714286;
29+
assertEquals(expected, solution1.closestValue(root, target));
30+
}
31+
32+
}

0 commit comments

Comments
 (0)