Skip to content

Commit b016405

Browse files
committed
Create average-of-levels-in-binary-tree_test.go
1 parent b780e85 commit b016405

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package average_of_levels_in_binary_tree
2+
3+
import (
4+
"reflect"
5+
"testing"
6+
)
7+
8+
func Test_averageOfLevels(t *testing.T) {
9+
type args struct {
10+
root *TreeNode
11+
}
12+
tests := []struct {
13+
name string
14+
args args
15+
want []float64
16+
}{
17+
{
18+
name: "test case 1",
19+
args: args{
20+
root: &TreeNode{
21+
Val: 3,
22+
Left: &TreeNode{
23+
Val: 9,
24+
},
25+
Right: &TreeNode{
26+
Val: 20,
27+
},
28+
},
29+
},
30+
want: []float64{3, 14.5},
31+
},
32+
}
33+
for _, tt := range tests {
34+
t.Run(tt.name, func(t *testing.T) {
35+
if got := averageOfLevels(tt.args.root); !reflect.DeepEqual(got, tt.want) {
36+
t.Errorf("averageOfLevels() = %v, want %v", got, tt.want)
37+
}
38+
})
39+
}
40+
}

0 commit comments

Comments
 (0)