|
|
|
@ -50,61 +50,61 @@ func TestGOPCache_Feed(t *testing.T) {
|
|
|
|
|
p4f := func() []byte { return []byte{0, 4} }
|
|
|
|
|
|
|
|
|
|
nc := NewGOPCache("rtmp", "test", 3)
|
|
|
|
|
assert.Equal(t, 0, nc.GetGopLen())
|
|
|
|
|
assert.Equal(t, nil, nc.GetGopDataAt(0))
|
|
|
|
|
assert.Equal(t, nil, nc.GetGopDataAt(1))
|
|
|
|
|
assert.Equal(t, nil, nc.GetGopDataAt(2))
|
|
|
|
|
assert.Equal(t, nil, nc.GetGopDataAt(3))
|
|
|
|
|
assert.Equal(t, 0, nc.GetGOPCount())
|
|
|
|
|
assert.Equal(t, nil, nc.GetGOPDataAt(0))
|
|
|
|
|
assert.Equal(t, nil, nc.GetGOPDataAt(1))
|
|
|
|
|
assert.Equal(t, nil, nc.GetGOPDataAt(2))
|
|
|
|
|
assert.Equal(t, nil, nc.GetGOPDataAt(3))
|
|
|
|
|
|
|
|
|
|
nc.Feed(i1, i1f)
|
|
|
|
|
assert.Equal(t, 1, nc.GetGopLen())
|
|
|
|
|
assert.Equal(t, [][]byte{{1, 1}}, nc.GetGopDataAt(0))
|
|
|
|
|
assert.Equal(t, nil, nc.GetGopDataAt(1))
|
|
|
|
|
assert.Equal(t, nil, nc.GetGopDataAt(2))
|
|
|
|
|
assert.Equal(t, nil, nc.GetGopDataAt(3))
|
|
|
|
|
assert.Equal(t, 1, nc.GetGOPCount())
|
|
|
|
|
assert.Equal(t, [][]byte{{1, 1}}, nc.GetGOPDataAt(0))
|
|
|
|
|
assert.Equal(t, nil, nc.GetGOPDataAt(1))
|
|
|
|
|
assert.Equal(t, nil, nc.GetGOPDataAt(2))
|
|
|
|
|
assert.Equal(t, nil, nc.GetGOPDataAt(3))
|
|
|
|
|
nc.Feed(p1, p1f)
|
|
|
|
|
assert.Equal(t, 1, nc.GetGopLen())
|
|
|
|
|
assert.Equal(t, [][]byte{{1, 1}, {0, 1}}, nc.GetGopDataAt(0))
|
|
|
|
|
assert.Equal(t, nil, nc.GetGopDataAt(1))
|
|
|
|
|
assert.Equal(t, nil, nc.GetGopDataAt(2))
|
|
|
|
|
assert.Equal(t, nil, nc.GetGopDataAt(3))
|
|
|
|
|
assert.Equal(t, 1, nc.GetGOPCount())
|
|
|
|
|
assert.Equal(t, [][]byte{{1, 1}, {0, 1}}, nc.GetGOPDataAt(0))
|
|
|
|
|
assert.Equal(t, nil, nc.GetGOPDataAt(1))
|
|
|
|
|
assert.Equal(t, nil, nc.GetGOPDataAt(2))
|
|
|
|
|
assert.Equal(t, nil, nc.GetGOPDataAt(3))
|
|
|
|
|
|
|
|
|
|
nc.Feed(i2, i2f)
|
|
|
|
|
assert.Equal(t, 2, nc.GetGopLen())
|
|
|
|
|
assert.Equal(t, [][]byte{{1, 1}, {0, 1}}, nc.GetGopDataAt(0))
|
|
|
|
|
assert.Equal(t, [][]byte{{1, 2}}, nc.GetGopDataAt(1))
|
|
|
|
|
assert.Equal(t, nil, nc.GetGopDataAt(2))
|
|
|
|
|
assert.Equal(t, nil, nc.GetGopDataAt(3))
|
|
|
|
|
assert.Equal(t, 2, nc.GetGOPCount())
|
|
|
|
|
assert.Equal(t, [][]byte{{1, 1}, {0, 1}}, nc.GetGOPDataAt(0))
|
|
|
|
|
assert.Equal(t, [][]byte{{1, 2}}, nc.GetGOPDataAt(1))
|
|
|
|
|
assert.Equal(t, nil, nc.GetGOPDataAt(2))
|
|
|
|
|
assert.Equal(t, nil, nc.GetGOPDataAt(3))
|
|
|
|
|
nc.Feed(p2, p2f)
|
|
|
|
|
assert.Equal(t, 2, nc.GetGopLen())
|
|
|
|
|
assert.Equal(t, [][]byte{{1, 1}, {0, 1}}, nc.GetGopDataAt(0))
|
|
|
|
|
assert.Equal(t, [][]byte{{1, 2}, {0, 2}}, nc.GetGopDataAt(1))
|
|
|
|
|
assert.Equal(t, nil, nc.GetGopDataAt(2))
|
|
|
|
|
assert.Equal(t, nil, nc.GetGopDataAt(3))
|
|
|
|
|
assert.Equal(t, 2, nc.GetGOPCount())
|
|
|
|
|
assert.Equal(t, [][]byte{{1, 1}, {0, 1}}, nc.GetGOPDataAt(0))
|
|
|
|
|
assert.Equal(t, [][]byte{{1, 2}, {0, 2}}, nc.GetGOPDataAt(1))
|
|
|
|
|
assert.Equal(t, nil, nc.GetGOPDataAt(2))
|
|
|
|
|
assert.Equal(t, nil, nc.GetGOPDataAt(3))
|
|
|
|
|
|
|
|
|
|
nc.Feed(i3, i3f)
|
|
|
|
|
assert.Equal(t, 3, nc.GetGopLen())
|
|
|
|
|
assert.Equal(t, [][]byte{{1, 1}, {0, 1}}, nc.GetGopDataAt(0))
|
|
|
|
|
assert.Equal(t, [][]byte{{1, 2}, {0, 2}}, nc.GetGopDataAt(1))
|
|
|
|
|
assert.Equal(t, [][]byte{{1, 3}}, nc.GetGopDataAt(2))
|
|
|
|
|
assert.Equal(t, nil, nc.GetGopDataAt(3))
|
|
|
|
|
assert.Equal(t, 3, nc.GetGOPCount())
|
|
|
|
|
assert.Equal(t, [][]byte{{1, 1}, {0, 1}}, nc.GetGOPDataAt(0))
|
|
|
|
|
assert.Equal(t, [][]byte{{1, 2}, {0, 2}}, nc.GetGOPDataAt(1))
|
|
|
|
|
assert.Equal(t, [][]byte{{1, 3}}, nc.GetGOPDataAt(2))
|
|
|
|
|
assert.Equal(t, nil, nc.GetGOPDataAt(3))
|
|
|
|
|
nc.Feed(p3, p3f)
|
|
|
|
|
assert.Equal(t, 3, nc.GetGopLen())
|
|
|
|
|
assert.Equal(t, [][]byte{{1, 1}, {0, 1}}, nc.GetGopDataAt(0))
|
|
|
|
|
assert.Equal(t, [][]byte{{1, 2}, {0, 2}}, nc.GetGopDataAt(1))
|
|
|
|
|
assert.Equal(t, [][]byte{{1, 3}, {0, 3}}, nc.GetGopDataAt(2))
|
|
|
|
|
assert.Equal(t, nil, nc.GetGopDataAt(3))
|
|
|
|
|
assert.Equal(t, 3, nc.GetGOPCount())
|
|
|
|
|
assert.Equal(t, [][]byte{{1, 1}, {0, 1}}, nc.GetGOPDataAt(0))
|
|
|
|
|
assert.Equal(t, [][]byte{{1, 2}, {0, 2}}, nc.GetGOPDataAt(1))
|
|
|
|
|
assert.Equal(t, [][]byte{{1, 3}, {0, 3}}, nc.GetGOPDataAt(2))
|
|
|
|
|
assert.Equal(t, nil, nc.GetGOPDataAt(3))
|
|
|
|
|
|
|
|
|
|
nc.Feed(i4, i4f)
|
|
|
|
|
assert.Equal(t, 3, nc.GetGopLen())
|
|
|
|
|
assert.Equal(t, [][]byte{{1, 2}, {0, 2}}, nc.GetGopDataAt(0))
|
|
|
|
|
assert.Equal(t, [][]byte{{1, 3}, {0, 3}}, nc.GetGopDataAt(1))
|
|
|
|
|
assert.Equal(t, [][]byte{{1, 4}}, nc.GetGopDataAt(2))
|
|
|
|
|
assert.Equal(t, nil, nc.GetGopDataAt(3))
|
|
|
|
|
assert.Equal(t, 3, nc.GetGOPCount())
|
|
|
|
|
assert.Equal(t, [][]byte{{1, 2}, {0, 2}}, nc.GetGOPDataAt(0))
|
|
|
|
|
assert.Equal(t, [][]byte{{1, 3}, {0, 3}}, nc.GetGOPDataAt(1))
|
|
|
|
|
assert.Equal(t, [][]byte{{1, 4}}, nc.GetGOPDataAt(2))
|
|
|
|
|
assert.Equal(t, nil, nc.GetGOPDataAt(3))
|
|
|
|
|
nc.Feed(p4, p4f)
|
|
|
|
|
assert.Equal(t, 3, nc.GetGopLen())
|
|
|
|
|
assert.Equal(t, [][]byte{{1, 2}, {0, 2}}, nc.GetGopDataAt(0))
|
|
|
|
|
assert.Equal(t, [][]byte{{1, 3}, {0, 3}}, nc.GetGopDataAt(1))
|
|
|
|
|
assert.Equal(t, [][]byte{{1, 4}, {0, 4}}, nc.GetGopDataAt(2))
|
|
|
|
|
assert.Equal(t, nil, nc.GetGopDataAt(3))
|
|
|
|
|
assert.Equal(t, 3, nc.GetGOPCount())
|
|
|
|
|
assert.Equal(t, [][]byte{{1, 2}, {0, 2}}, nc.GetGOPDataAt(0))
|
|
|
|
|
assert.Equal(t, [][]byte{{1, 3}, {0, 3}}, nc.GetGOPDataAt(1))
|
|
|
|
|
assert.Equal(t, [][]byte{{1, 4}, {0, 4}}, nc.GetGOPDataAt(2))
|
|
|
|
|
assert.Equal(t, nil, nc.GetGOPDataAt(3))
|
|
|
|
|
}
|
|
|
|
|