You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
v2ray-core/common/mux/session_test.go

52 lines
738 B

package mux_test
import (
"testing"
. "v2ray.com/core/common/mux"
)
func TestSessionManagerAdd(t *testing.T) {
m := NewSessionManager()
s := m.Allocate()
if s.ID != 1 {
t.Error("id: ", s.ID)
}
if m.Size() != 1 {
t.Error("size: ", m.Size())
}
s = m.Allocate()
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)
if s.ID != 4 {
t.Error("id: ", s.ID)
}
if m.Size() != 3 {
t.Error("size: ", m.Size())
}
}
8 years ago
func TestSessionManagerClose(t *testing.T) {
m := NewSessionManager()
s := m.Allocate()
if m.CloseIfNoSession() {
t.Error("able to close")
}
8 years ago
m.Remove(s.ID)
if !m.CloseIfNoSession() {
t.Error("not able to close")
}
8 years ago
}