libgo: update to go1.9
[official-gcc.git] / libgo / go / internal / poll / writev_test.go
blobb46657ce960239c67dff21e0926be3bdebd3a96c
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.
5 package poll_test
7 import (
8 "internal/poll"
9 "reflect"
10 "testing"
13 func TestConsume(t *testing.T) {
14 tests := []struct {
15 in [][]byte
16 consume int64
17 want [][]byte
20 in: [][]byte{[]byte("foo"), []byte("bar")},
21 consume: 0,
22 want: [][]byte{[]byte("foo"), []byte("bar")},
25 in: [][]byte{[]byte("foo"), []byte("bar")},
26 consume: 2,
27 want: [][]byte{[]byte("o"), []byte("bar")},
30 in: [][]byte{[]byte("foo"), []byte("bar")},
31 consume: 3,
32 want: [][]byte{[]byte("bar")},
35 in: [][]byte{[]byte("foo"), []byte("bar")},
36 consume: 4,
37 want: [][]byte{[]byte("ar")},
40 in: [][]byte{nil, nil, nil, []byte("bar")},
41 consume: 1,
42 want: [][]byte{[]byte("ar")},
45 in: [][]byte{nil, nil, nil, []byte("foo")},
46 consume: 0,
47 want: [][]byte{[]byte("foo")},
50 in: [][]byte{nil, nil, nil},
51 consume: 0,
52 want: [][]byte{},
55 for i, tt := range tests {
56 in := tt.in
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)