1 // Copyright 2016 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
13 func TestConsume(t
*testing
.T
) {
20 in
: [][]byte{[]byte("foo"), []byte("bar")},
22 want
: [][]byte{[]byte("foo"), []byte("bar")},
25 in
: [][]byte{[]byte("foo"), []byte("bar")},
27 want
: [][]byte{[]byte("o"), []byte("bar")},
30 in
: [][]byte{[]byte("foo"), []byte("bar")},
32 want
: [][]byte{[]byte("bar")},
35 in
: [][]byte{[]byte("foo"), []byte("bar")},
37 want
: [][]byte{[]byte("ar")},
40 in
: [][]byte{nil, nil, nil, []byte("bar")},
42 want
: [][]byte{[]byte("ar")},
45 in
: [][]byte{nil, nil, nil, []byte("foo")},
47 want
: [][]byte{[]byte("foo")},
50 in
: [][]byte{nil, nil, nil},
55 for i
, tt
:= range tests
{
57 poll
.Consume(&in
, tt
.consume
)
58 if !reflect
.DeepEqual(in
, tt
.want
) {
59 t
.Errorf("%d. after consume(%d) = %+v, want %+v", i
, tt
.consume
, in
, tt
.want
)