1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2025-12-31 22:45:39 -05:00

remove dep of assert lib

This commit is contained in:
Darien Raymond
2019-02-10 15:02:28 +01:00
parent a84897b4b6
commit 98950d5ada
14 changed files with 416 additions and 326 deletions

View File

@@ -4,36 +4,48 @@ import (
"testing"
. "v2ray.com/core/common/mux"
. "v2ray.com/ext/assert"
)
func TestSessionManagerAdd(t *testing.T) {
assert := With(t)
m := NewSessionManager()
s := m.Allocate()
assert(s.ID, Equals, uint16(1))
assert(m.Size(), Equals, 1)
if s.ID != 1 {
t.Error("id: ", s.ID)
}
if m.Size() != 1 {
t.Error("size: ", m.Size())
}
s = m.Allocate()
assert(s.ID, Equals, uint16(2))
assert(m.Size(), Equals, 2)
if s.ID != 2 {
t.Error("id: ", s.ID)
}
if m.Size() != 2 {
t.Error("size: ", m.Size())
}
s = &Session{
ID: 4,
}
m.Add(s)
assert(s.ID, Equals, uint16(4))
if s.ID != 4 {
t.Error("id: ", s.ID)
}
if m.Size() != 3 {
t.Error("size: ", m.Size())
}
}
func TestSessionManagerClose(t *testing.T) {
assert := With(t)
m := NewSessionManager()
s := m.Allocate()
assert(m.CloseIfNoSession(), IsFalse)
if m.CloseIfNoSession() {
t.Error("able to close")
}
m.Remove(s.ID)
assert(m.CloseIfNoSession(), IsTrue)
if !m.CloseIfNoSession() {
t.Error("not able to close")
}
}