mirror of
https://github.com/bluenviron/mediamtx
synced 2025-01-07 07:20:01 +00:00
rtmp: add tests
This commit is contained in:
parent
58cbd072c8
commit
06b09efa91
21
internal/rtmp/bytecounter/reader_test.go
Normal file
21
internal/rtmp/bytecounter/reader_test.go
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
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)
|
||||||
|
buf2 := make([]byte, 64)
|
||||||
|
n, err := r.Read(buf2)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Equal(t, 64, n)
|
||||||
|
|
||||||
|
require.Equal(t, uint32(1024), r.Count())
|
||||||
|
}
|
15
internal/rtmp/bytecounter/writer_test.go
Normal file
15
internal/rtmp/bytecounter/writer_test.go
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
package bytecounter
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestWriter(t *testing.T) {
|
||||||
|
var buf bytes.Buffer
|
||||||
|
w := NewWriter(&buf)
|
||||||
|
w.Write(bytes.Repeat([]byte{0x01}, 64))
|
||||||
|
require.Equal(t, uint32(64), w.Count())
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user