1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-07-12 16:24:19 -04:00
v2fly/transport/internet/kcp/sending_test.go

43 lines
851 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/transport/internet/kcp"
2017-10-24 10:15:35 -04:00
. "v2ray.com/ext/assert"
2016-06-26 17:51:17 -04:00
)
2016-07-01 05:57:13 -04:00
func TestSendingWindow(t *testing.T) {
2017-10-24 10:15:35 -04:00
assert := With(t)
2016-07-01 05:57:13 -04:00
2016-07-04 11:01:32 -04:00
window := NewSendingWindow(5, nil, nil)
2016-11-01 07:07:20 -04:00
window.Push(0, []byte{})
window.Push(1, []byte{})
window.Push(2, []byte{})
2017-10-24 10:15:35 -04:00
assert(window.Len(), Equals, 3)
2016-07-01 05:57:13 -04:00
window.Remove(1)
2017-10-24 10:15:35 -04:00
assert(window.Len(), Equals, 3)
assert(window.FirstNumber(), Equals, uint32(0))
2016-07-01 05:57:13 -04:00
window.Remove(0)
2017-10-24 10:15:35 -04:00
assert(window.Len(), Equals, 1)
assert(window.FirstNumber(), Equals, uint32(2))
2016-07-01 05:57:13 -04:00
window.Remove(0)
2017-10-24 10:15:35 -04:00
assert(window.Len(), Equals, 0)
2016-07-01 05:57:13 -04:00
2016-11-01 07:07:20 -04:00
window.Push(4, []byte{})
2017-10-24 10:15:35 -04:00
assert(window.Len(), Equals, 1)
assert(window.FirstNumber(), Equals, uint32(4))
2016-11-01 07:07:20 -04:00
window.Push(5, []byte{})
2017-10-24 10:15:35 -04:00
assert(window.Len(), Equals, 2)
window.Remove(1)
2017-10-24 10:15:35 -04:00
assert(window.Len(), Equals, 2)
window.Remove(0)
2017-10-24 10:15:35 -04:00
assert(window.Len(), Equals, 0)
2016-07-01 05:57:13 -04:00
}