-
Notifications
You must be signed in to change notification settings - Fork 1
/
testing_test.go
51 lines (44 loc) · 965 Bytes
/
testing_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 bip32_test
import (
"reflect"
"testing"
"github.com/sammyne/bip32"
)
// dummy test for coverage report
func TestPath_ChildIndices(t *testing.T) {
type expect struct {
indices []*bip32.ChildIndex
hasErr bool
}
testCases := []struct {
path bip32.Path
expect expect
}{
{ // good path
"m/0/123H",
expect{
[]*bip32.ChildIndex{
{Index: 0, Hardened: false},
{Index: 123, Hardened: true},
},
false,
},
},
{ // path contains invalid child index
"m/0 /123H",
expect{nil, true},
},
}
for i, c := range testCases {
got, err := c.path.ChildIndices()
if nil != err && !c.expect.hasErr {
t.Fatalf("#%d unexpected error: %v", i, err)
} else if nil == err && c.expect.hasErr {
t.Fatalf("#%d expect error but got none", i)
}
if nil == err && !reflect.DeepEqual(got, c.expect.indices) {
t.Fatalf("#%d invalid child indices: got %#v, expect %#v", i, got,
c.expect.indices)
}
}
}