github.com/golangci/go-tools@v0.0.0-20190318060251-af6baa5dc196/unused/testdata/src/exported_method_test/exported_method_test.go (about) 1 package pkg 2 3 import ( 4 "bytes" 5 "io" 6 "io/ioutil" 7 "testing" 8 ) 9 10 type countReadSeeker struct { 11 io.ReadSeeker 12 N int64 13 } 14 15 func (rs *countReadSeeker) Read(buf []byte) (int, error) { 16 n, err := rs.ReadSeeker.Read(buf) 17 rs.N += int64(n) 18 return n, err 19 } 20 21 func TestFoo(t *testing.T) { 22 r := bytes.NewReader([]byte("Hello, world!")) 23 cr := &countReadSeeker{ReadSeeker: r} 24 ioutil.ReadAll(cr) 25 if cr.N != 13 { 26 t.Errorf("got %d, want 13", cr.N) 27 } 28 }