-
Notifications
You must be signed in to change notification settings - Fork 2
/
depth_first_test.go
38 lines (30 loc) · 1.08 KB
/
depth_first_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
package leaflist_test
import (
"reflect"
"testing"
leaflist "github.com/ju-popov/structy.net/037-leaf-list"
)
func TestDepthFirst(t *testing.T) {
t.Parallel()
for _, testCase := range testCases {
testCase := testCase
t.Run(testCase.name, func(t *testing.T) {
t.Parallel()
actual := leaflist.DepthFirst(testCase.root)
if !reflect.DeepEqual(actual, testCase.expected) {
t.Errorf("Expected result for test name: '%v' is: '%v', but the actual result is: '%v'", testCase.name, testCase.expected, actual)
}
})
}
}
func benchmarkDepthFirst(b *testing.B, testCase testCase) {
b.Helper()
for n := 0; n < b.N; n++ {
leaflist.DepthFirst(testCase.root)
}
}
func BenchmarkDepthFirst000(b *testing.B) { benchmarkDepthFirst(b, testCases[0]) }
func BenchmarkDepthFirst001(b *testing.B) { benchmarkDepthFirst(b, testCases[1]) }
func BenchmarkDepthFirst002(b *testing.B) { benchmarkDepthFirst(b, testCases[2]) }
func BenchmarkDepthFirst003(b *testing.B) { benchmarkDepthFirst(b, testCases[3]) }
func BenchmarkDepthFirst004(b *testing.B) { benchmarkDepthFirst(b, testCases[4]) }