mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-09-06 03:54:22 -04:00
34 lines
569 B
Go
34 lines
569 B
Go
package alloc
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/v2ray/v2ray-core/testing/unit"
|
|
)
|
|
|
|
func TestBufferClear(t *testing.T) {
|
|
assert := unit.Assert(t)
|
|
|
|
buffer := NewBuffer().Clear()
|
|
defer buffer.Release()
|
|
|
|
payload := "Bytes"
|
|
buffer.Append([]byte(payload))
|
|
assert.Int(buffer.Len()).Equals(len(payload))
|
|
|
|
buffer.Clear()
|
|
assert.Int(buffer.Len()).Equals(0)
|
|
}
|
|
|
|
func TestBufferIsFull(t *testing.T) {
|
|
assert := unit.Assert(t)
|
|
|
|
buffer := NewBuffer()
|
|
defer buffer.Release()
|
|
|
|
assert.Bool(buffer.IsFull()).IsTrue()
|
|
|
|
buffer.Clear()
|
|
assert.Bool(buffer.IsFull()).IsFalse()
|
|
}
|