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