mirror of
https://github.com/aler9/gortsplib
synced 2025-10-06 07:37:07 +08:00
add more efficient bit reader / writer
This commit is contained in:
18
pkg/bits/write_test.go
Normal file
18
pkg/bits/write_test.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package bits
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestWriteBits(t *testing.T) {
|
||||
buf := make([]byte, 6)
|
||||
pos := 0
|
||||
WriteBits(buf, &pos, uint64(0x2a), 6)
|
||||
WriteBits(buf, &pos, uint64(0x0c), 6)
|
||||
WriteBits(buf, &pos, uint64(0x1f), 6)
|
||||
WriteBits(buf, &pos, uint64(0x5a), 8)
|
||||
WriteBits(buf, &pos, uint64(0xaaec4), 20)
|
||||
require.Equal(t, []byte{0xA8, 0xC7, 0xD6, 0xAA, 0xBB, 0x10}, buf)
|
||||
}
|
Reference in New Issue
Block a user