mirror of
https://github.com/v2fly/v2ray-core.git
synced 2026-01-02 07:25:19 -05:00
sending window
This commit is contained in:
@@ -62,3 +62,36 @@ func TestSendingQueueClear(t *testing.T) {
|
||||
queue.Clear()
|
||||
assert.Bool(queue.IsEmpty()).IsTrue()
|
||||
}
|
||||
|
||||
func TestSendingWindow(t *testing.T) {
|
||||
assert := assert.On(t)
|
||||
|
||||
window := NewSendingWindow(nil, 5)
|
||||
window.Push(&DataSegment{
|
||||
Number: 0,
|
||||
})
|
||||
window.Push(&DataSegment{
|
||||
Number: 1,
|
||||
})
|
||||
window.Push(&DataSegment{
|
||||
Number: 2,
|
||||
})
|
||||
assert.Int(window.Len()).Equals(3)
|
||||
|
||||
window.Remove(1)
|
||||
assert.Int(window.Len()).Equals(3)
|
||||
assert.Uint32(window.First().Number).Equals(0)
|
||||
|
||||
window.Remove(0)
|
||||
assert.Int(window.Len()).Equals(1)
|
||||
assert.Uint32(window.First().Number).Equals(2)
|
||||
|
||||
window.Remove(0)
|
||||
assert.Int(window.Len()).Equals(0)
|
||||
|
||||
window.Push(&DataSegment{
|
||||
Number: 4,
|
||||
})
|
||||
assert.Int(window.Len()).Equals(1)
|
||||
assert.Uint32(window.First().Number).Equals(4)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user