mirror of
https://github.com/bluenviron/mediamtx
synced 2025-01-28 18:12:53 +00:00
8bee4af86a
* API: number of bytes received/sent from/to RTSP connections * API: number of bytes received/sent from/to RTSP sessions * API: number of bytes received/sent from/to RTMP connections * API: number of bytes sent to HLS connections * API: number of bytes received from paths * metrics of all the above
24 lines
381 B
Go
24 lines
381 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, uint64(100+64), r.Count())
|
|
}
|