github.com/hamba/avro@v1.8.0/internal/bytesx/reset_test.go (about) 1 package bytesx_test 2 3 import ( 4 "io" 5 "testing" 6 7 "github.com/hamba/avro/internal/bytesx" 8 "github.com/stretchr/testify/assert" 9 ) 10 11 func TestNewResetReader(t *testing.T) { 12 r := bytesx.NewResetReader([]byte{}) 13 14 assert.IsType(t, &bytesx.ResetReader{}, r) 15 assert.Implements(t, (*io.Reader)(nil), r) 16 } 17 18 func TestResetReader_Read(t *testing.T) { 19 r := bytesx.NewResetReader([]byte("test")) 20 21 b := make([]byte, 4) 22 n, err := r.Read(b) 23 24 assert.NoError(t, err) 25 assert.Equal(t, 4, n) 26 assert.Equal(t, []byte("test"), b) 27 } 28 29 func TestResetReader_ReadReturnsEOF(t *testing.T) { 30 r := bytesx.NewResetReader([]byte{}) 31 32 b := make([]byte, 4) 33 n, err := r.Read(b) 34 35 assert.Equal(t, io.EOF, err) 36 assert.Equal(t, 0, n) 37 }