mediamtx/internal/rtmp/bytecounter/reader_test.go
2022-07-16 12:42:48 +02:00

24 lines
383 B
Go

package bytecounter
import (
"bytes"
"testing"
"github.com/stretchr/testify/require"
)
func TestReader(t *testing.T) {
var buf bytes.Buffer
buf.Write(bytes.Repeat([]byte{0x01}, 1024))
r := NewReader(&buf)
r.SetCount(100)
buf2 := make([]byte, 64)
n, err := r.Read(buf2)
require.NoError(t, err)
require.Equal(t, 64, n)
require.Equal(t, uint32(100+1024), r.Count())
}