8 func TestReadKey(t
*testing
.T
) {
9 for _
, test
:= range []struct {
14 {"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcde", nil},
15 {"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef", []byte("\x01\x23\x45\x67\x89\xab\xcd\xef\x01\x23\x45\x67\x89\xab\xcd\xef\x01\x23\x45\x67\x89\xab\xcd\xef\x01\x23\x45\x67\x89\xab\xcd\xef")},
16 {"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\n", []byte("\x01\x23\x45\x67\x89\xab\xcd\xef\x01\x23\x45\x67\x89\xab\xcd\xef\x01\x23\x45\x67\x89\xab\xcd\xef\x01\x23\x45\x67\x89\xab\xcd\xef")},
17 {"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0", nil},
18 {"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\nX", nil},
19 {"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\n\n", nil},
20 {"\n0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef", nil},
21 {"X123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef", nil},
22 {"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", nil},
24 output
, err
:= ReadKey(bytes
.NewReader([]byte(test
.input
)))
25 if test
.output
== nil {
27 t
.Errorf("%+q expected error", test
.input
)
31 t
.Errorf("%+q returned error %v", test
.input
, err
)
32 } else if !bytes
.Equal(output
, test
.output
) {
33 t
.Errorf("%+q got %x, expected %x", test
.input
, output
, test
.output
)