1
1
package com.github.masx200.leetcode_test.construct_binary_search_tree_from_preorder_traversal
2
2
3
+ import com.cedarsoftware.util.DeepEquals.deepEquals
4
+ import com.github.masx200.leetcode_test.utils.TreeNodeLeetCodeParse
3
5
4
6
import com.github.masx200.leetcode_test.utils.TreeNodeLeetCodeStringify
5
7
import kotlinx.serialization.encodeToString
6
8
import kotlinx.serialization.json.Json
7
9
import org.junit.jupiter.api.Assertions.assertEquals
8
10
import org.junit.jupiter.api.Test
11
+ import kotlin.test.assertTrue
9
12
10
13
internal class SolutionTest {
11
14
12
15
@Test
13
- fun bstFromPreorder () {
16
+ fun testbstFromPreorder () {
14
17
15
18
assertEquals(
16
19
listOf (intArrayOf(8 , 5 , 1 , 7 , 10 , 12 ), intArrayOf(1 , 3 )).map { Solution ().bstFromPreorder(it) }
17
20
.map { TreeNodeLeetCodeStringify (it) },
18
21
listOf (arrayOf(8 , 5 , 10 , 1 , 7 , null , 12 ), arrayOf(1 , null , 3 )).map { Json .encodeToString(it) }
19
22
)
23
+
24
+ assertTrue(
25
+ deepEquals(
26
+ listOf (intArrayOf(8 , 5 , 1 , 7 , 10 , 12 ), intArrayOf(1 , 3 )).map { Solution ().bstFromPreorder(it) },
27
+ listOf (arrayOf(8 , 5 , 10 , 1 , 7 , null , 12 ), arrayOf(1 , null , 3 )).map { Json .encodeToString(it) }
28
+ .map { TreeNodeLeetCodeParse (it) }
29
+
30
+ )
31
+ )
20
32
}
21
33
}
0 commit comments