v2ray-core/transport/internet/kcp/sending_test.go

43 lines
881 B
Go
Raw Normal View History

2016-06-26 21:51:17 +00:00
package kcp_test
import (
"testing"
2016-08-20 18:55:45 +00:00
"v2ray.com/core/testing/assert"
. "v2ray.com/core/transport/internet/kcp"
2016-06-26 21:51:17 +00:00
)
2016-07-01 09:57:13 +00:00
func TestSendingWindow(t *testing.T) {
assert := assert.On(t)
2016-07-04 15:01:32 +00:00
window := NewSendingWindow(5, nil, nil)
2016-11-01 11:07:20 +00:00
window.Push(0, []byte{})
window.Push(1, []byte{})
window.Push(2, []byte{})
2016-07-01 09:57:13 +00:00
assert.Int(window.Len()).Equals(3)
window.Remove(1)
assert.Int(window.Len()).Equals(3)
2016-11-01 11:07:20 +00:00
assert.Uint32(window.FirstNumber()).Equals(0)
2016-07-01 09:57:13 +00:00
window.Remove(0)
assert.Int(window.Len()).Equals(1)
2016-11-01 11:07:20 +00:00
assert.Uint32(window.FirstNumber()).Equals(2)
2016-07-01 09:57:13 +00:00
window.Remove(0)
assert.Int(window.Len()).Equals(0)
2016-11-01 11:07:20 +00:00
window.Push(4, []byte{})
2016-07-01 09:57:13 +00:00
assert.Int(window.Len()).Equals(1)
2016-11-01 11:07:20 +00:00
assert.Uint32(window.FirstNumber()).Equals(4)
2016-11-01 11:07:20 +00:00
window.Push(5, []byte{})
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 09:57:13 +00:00
}