// Copyright 2024 Matthew Rich <matthewrich.conf@gmail.com>. All rights reserved.

package iofilter

import (
	"github.com/stretchr/testify/assert"
	"testing"
	"strings"
)

func TestNewReader(t *testing.T) {
	buffer := make([]byte, 20)
	reader := NewReader(strings.NewReader("testdata"), func(p []byte, in int, e error) (int, error) {
		copy(p, []byte("foo"))
		return 3, nil
	})
	assert.NotNil(t, reader)
	sz, e := reader.Read(buffer)
	assert.Nil(t, e)
	assert.Equal(t, 3, sz)
	assert.Equal(t, "foo", string(buffer[:3]))
}
