mse: Move sliceIter into test file

This commit is contained in:
Matt Joiner 2017-11-04 17:07:42 +11:00
parent dd1bc6b837
commit 9bf50493c3
2 changed files with 10 additions and 10 deletions

View File

@ -548,16 +548,6 @@ func ReceiveHandshake(rw io.ReadWriter, skeys SecretKeyIter, selectCrypto func(u
return h.Do()
}
func sliceIter(skeys [][]byte) SecretKeyIter {
return func(callback func([]byte) bool) {
for _, sk := range skeys {
if !callback(sk) {
break
}
}
}
}
// A function that given a function, calls it with secret keys until it
// returns false or exhausted.
type SecretKeyIter func(callback func(skey []byte) (more bool))

View File

@ -16,6 +16,16 @@ import (
"github.com/stretchr/testify/require"
)
func sliceIter(skeys [][]byte) SecretKeyIter {
return func(callback func([]byte) bool) {
for _, sk := range skeys {
if !callback(sk) {
break
}
}
}
}
func TestReadUntil(t *testing.T) {
test := func(data, until string, leftover int, expectedErr error) {
r := bytes.NewReader([]byte(data))