-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdup_trees_test.go
51 lines (45 loc) · 950 Bytes
/
dup_trees_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package problem0652
import (
"fmt"
. "leetcodedaily/helpers/binarytree"
"testing"
"github.com/stretchr/testify/assert"
)
type Result struct {
Input *TreeNode
Expected []*TreeNode
}
var Results = []Result{
{
MakeTree(1, 2, 4, NULL, NULL, NULL, 3, 2, 4, NULL, NULL, NULL, 4, NULL, NULL),
[]*TreeNode{
MakeTree(4, NULL, NULL),
MakeTree(2, 4, NULL, NULL, NULL),
},
},
{
MakeTree(2, 1, NULL, NULL, 1, NULL, NULL),
[]*TreeNode{
MakeTree(1, NULL, NULL),
},
},
{
MakeTree(2, 2, 3, NULL, NULL, NULL, 2, 3, NULL, NULL, NULL),
[]*TreeNode{
MakeTree(3, NULL, NULL),
MakeTree(2, 3, NULL, NULL, NULL),
},
},
{
MakeTree(2, 1, 11, NULL, NULL, NULL, 11, 1, NULL, NULL, NULL),
nil,
},
}
func TestFindDuplicateTrees(t *testing.T) {
assert := assert.New(t)
for _, res := range Results {
want := res.Expected
got := findDuplicateSubtrees(res.Input)
assert.Equal(want, got, fmt.Sprintf("%+v", res))
}
}