Skip to content

Commit f1f7fdd

Browse files
committed
测试
1 parent e216fb2 commit f1f7fdd

File tree

4 files changed

+55
-6
lines changed

4 files changed

+55
-6
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package index
2+
3+
import (
4+
"strings"
5+
"testing"
6+
7+
"github.com/magiconair/properties/assert"
8+
"github.com/masx200/leetcode-test/utils"
9+
)
10+
11+
var SerializeBinaryTree = utils.TreeNodeLeetCodeStringify
12+
13+
func TestConstructMaximumBinaryTree(t *testing.T) {
14+
var inputs = [][]int{
15+
{3, 2, 1, 6, 0, 5},
16+
{3, 2, 1},
17+
}
18+
var outputs = []string{
19+
"[6, 3, 5, null, 2, 0, null, null, 1]",
20+
"[3, null, 2, null, 1]",
21+
}
22+
23+
for i := 0; i < len(inputs); i++ {
24+
var result = constructMaximumBinaryTree(inputs[i])
25+
var output = strings.ReplaceAll(outputs[i], " ", "")
26+
var serialized = SerializeBinaryTree(result)
27+
assert.Equal(t, output, serialized)
28+
}
29+
}

maximum-binary-tree/export.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
package index
2-
3-
func ConstructMaximumBinaryTree(nums []int) *TreeNode {
4-
return constructMaximumBinaryTree(nums)
5-
}
1+
package index
2+
3+
func ConstructMaximumBinaryTree(nums []int) *TreeNode {
4+
return constructMaximumBinaryTree(nums)
5+
}

maximum-binary-tree/go.mod

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,18 @@ go 1.19
44

55
require github.com/masx200/leetcode-test/serialize-and-deserialize-binary-tree v0.0.0
66

7-
require github.com/masx200/leetcode-test/maximum-binary-tree-ii v0.0.0
7+
require (
8+
github.com/magiconair/properties v1.8.6
9+
github.com/masx200/leetcode-test/maximum-binary-tree-ii v0.0.0
10+
)
11+
12+
require (
13+
github.com/egregors/TreeNode v1.0.3 // indirect
14+
github.com/masx200/leetcode-test/utils v0.0.0-20220820053119-e216fb249226
15+
)
816

917
replace github.com/masx200/leetcode-test/maximum-binary-tree-ii v0.0.0 => ../maximum-binary-tree-ii
1018

1119
replace github.com/masx200/leetcode-test/serialize-and-deserialize-binary-tree v0.0.0 => ../serialize-and-deserialize-binary-tree
20+
21+
replace github.com/masx200/leetcode-test/utils v0.0.0 => ../utils

maximum-binary-tree/go.sum

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,12 @@
1+
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
2+
github.com/egregors/TreeNode v1.0.3 h1:oSel21BpUt99TWGrFJ1QbSBBEeQSdwOqOpX9eSqILNE=
3+
github.com/egregors/TreeNode v1.0.3/go.mod h1:c2sTJKaqtn/Ju3J7rFi6RvJqbLFAEObRDJP6yqRCdaA=
14
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
5+
github.com/magiconair/properties v1.8.6 h1:5ibWZ6iY0NctNGWo87LalDlEZ6R41TqbbDamhfG/Qzo=
6+
github.com/magiconair/properties v1.8.6/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60=
7+
github.com/masx200/leetcode-test/utils v0.0.0-20220820053119-e216fb249226 h1:8cY/xRiNHRBHMfdg25vpKo2G844UuaD0b+N1chA/wWg=
8+
github.com/masx200/leetcode-test/utils v0.0.0-20220820053119-e216fb249226/go.mod h1:RfG4GmC53AWWULNonMFnocUkaX7+fzZWkT/IXdV2KPQ=
9+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
10+
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
11+
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
212
gotest.tools/v3 v3.3.0 h1:MfDY1b1/0xN1CyMlQDac0ziEy9zJQd9CXBRRDHw2jJo=

0 commit comments

Comments
 (0)