mirror of
https://github.com/langhuihui/monibuca.git
synced 2025-10-24 19:30:22 +08:00
feat: play rtsp h264
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestBuffer(t *testing.T) {
|
||||
@@ -16,3 +18,32 @@ func TestBuffer(t *testing.T) {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestReadBytesTo(t *testing.T) {
|
||||
t.Run(t.Name(), func(t *testing.T) {
|
||||
s := RandomString(100)
|
||||
t.Logf("s:%s", s)
|
||||
var m Memory
|
||||
m.Append([]byte(s))
|
||||
r := m.NewReader()
|
||||
seededRand := rand.New(rand.NewSource(time.Now().UnixNano()))
|
||||
var total []byte
|
||||
for {
|
||||
i := seededRand.Intn(10)
|
||||
if i == 0 {
|
||||
continue
|
||||
}
|
||||
buf := make([]byte, i)
|
||||
n := r.ReadBytesTo(buf)
|
||||
t.Logf("n:%d buf:%s", n, string(buf))
|
||||
total = append(total, buf[:n]...)
|
||||
if n == 0 {
|
||||
if string(total) != s {
|
||||
t.Logf("total:%s", total)
|
||||
t.Fail()
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user