1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-09-16 00:48:14 -04:00
v2fly/transport/internet/kcp/sending_test.go

53 lines
974 B
Go
Raw Normal View History

2016-06-26 17:51:17 -04:00
package kcp_test
import (
"testing"
2016-08-20 14:55:45 -04:00
"v2ray.com/core/testing/assert"
. "v2ray.com/core/transport/internet/kcp"
2016-06-26 17:51:17 -04:00
)
2016-07-01 05:57:13 -04:00
func TestSendingWindow(t *testing.T) {
assert := assert.On(t)
2016-07-04 11:01:32 -04:00
window := NewSendingWindow(5, nil, nil)
2016-07-01 05:57:13 -04:00
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)
window.Push(&DataSegment{
Number: 5,
})
assert.Int(window.Len()).Equals(2)
window.Remove(1)
assert.Int(window.Len()).Equals(2)
window.Remove(0)
assert.Int(window.Len()).Equals(0)
2016-07-01 05:57:13 -04:00
}