1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-23 10:37:09 -05:00
v2fly/transport/internet/kcp/receiving_test.go

35 lines
686 B
Go
Raw Normal View History

2016-06-25 15:35:18 -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-25 15:35:18 -04:00
)
func TestRecivingWindow(t *testing.T) {
2017-10-24 10:15:35 -04:00
assert := With(t)
2016-06-25 15:35:18 -04:00
window := NewReceivingWindow(3)
2016-06-29 04:34:34 -04:00
seg0 := &DataSegment{}
seg1 := &DataSegment{}
seg2 := &DataSegment{}
seg3 := &DataSegment{}
2016-06-25 15:35:18 -04:00
2017-10-24 10:15:35 -04:00
assert(window.Set(0, seg0), IsTrue)
assert(window.RemoveFirst(), Equals, seg0)
2016-06-27 03:03:05 -04:00
e := window.RemoveFirst()
2017-10-24 10:15:35 -04:00
assert(e, IsNil)
2016-06-25 15:35:18 -04:00
2017-10-24 10:15:35 -04:00
assert(window.Set(1, seg1), IsTrue)
assert(window.Set(2, seg2), IsTrue)
2016-06-25 15:35:18 -04:00
window.Advance()
2017-10-24 10:15:35 -04:00
assert(window.Set(2, seg3), IsTrue)
2016-06-25 15:35:18 -04:00
2017-10-24 10:15:35 -04:00
assert(window.RemoveFirst(), Equals, seg1)
assert(window.Remove(1), Equals, seg2)
assert(window.Remove(2), Equals, seg3)
2016-06-25 15:35:18 -04:00
}