mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-09-07 04:24:23 -04:00
65 lines
1.2 KiB
Go
65 lines
1.2 KiB
Go
package kcp_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/v2ray/v2ray-core/testing/assert"
|
|
. "github.com/v2ray/v2ray-core/transport/internet/kcp"
|
|
)
|
|
|
|
func TestSendingQueue(t *testing.T) {
|
|
assert := assert.On(t)
|
|
|
|
queue := NewSendingQueue(3)
|
|
|
|
seg0 := &DataSegment{}
|
|
seg1 := &DataSegment{}
|
|
seg2 := &DataSegment{}
|
|
seg3 := &DataSegment{}
|
|
|
|
assert.Bool(queue.IsEmpty()).IsTrue()
|
|
assert.Bool(queue.IsFull()).IsFalse()
|
|
|
|
queue.Push(seg0)
|
|
assert.Bool(queue.IsEmpty()).IsFalse()
|
|
|
|
queue.Push(seg1)
|
|
queue.Push(seg2)
|
|
|
|
assert.Bool(queue.IsFull()).IsTrue()
|
|
|
|
assert.Pointer(queue.Pop()).Equals(seg0)
|
|
|
|
queue.Push(seg3)
|
|
assert.Bool(queue.IsFull()).IsTrue()
|
|
|
|
assert.Pointer(queue.Pop()).Equals(seg1)
|
|
assert.Pointer(queue.Pop()).Equals(seg2)
|
|
assert.Pointer(queue.Pop()).Equals(seg3)
|
|
assert.Int(int(queue.Len())).Equals(0)
|
|
}
|
|
|
|
func TestSendingQueueClear(t *testing.T) {
|
|
assert := assert.On(t)
|
|
|
|
queue := NewSendingQueue(3)
|
|
|
|
seg0 := &DataSegment{}
|
|
seg1 := &DataSegment{}
|
|
seg2 := &DataSegment{}
|
|
seg3 := &DataSegment{}
|
|
|
|
queue.Push(seg0)
|
|
assert.Bool(queue.IsEmpty()).IsFalse()
|
|
|
|
queue.Clear()
|
|
assert.Bool(queue.IsEmpty()).IsTrue()
|
|
|
|
queue.Push(seg1)
|
|
queue.Push(seg2)
|
|
queue.Push(seg3)
|
|
|
|
queue.Clear()
|
|
assert.Bool(queue.IsEmpty()).IsTrue()
|
|
}
|