diff --git a/capability.go b/capability.go index ed84adc3a..7b291f38c 100644 --- a/capability.go +++ b/capability.go @@ -16,7 +16,7 @@ type listCapabilities struct { data []Capability } -func NewCapabilites() Capabilities { +func NewCapabilities() Capabilities { return &listCapabilities{ data: make([]Capability, 0, 16), } diff --git a/capability_test.go b/capability_test.go new file mode 100644 index 000000000..100daeb72 --- /dev/null +++ b/capability_test.go @@ -0,0 +1,21 @@ +package core + +import ( + "testing" + + "github.com/v2ray/v2ray-core/testing/unit" +) + +func TestCapabilities(t *testing.T) { + assert := unit.Assert(t) + + caps := NewCapabilities() + assert.Bool(caps.HasCapability(TCPConnection)).IsFalse() + + caps.AddCapability(TCPConnection) + assert.Bool(caps.HasCapability(TCPConnection)).IsTrue() + + caps.AddCapability(UDPConnection) + assert.Bool(caps.HasCapability(TCPConnection)).IsTrue() + assert.Bool(caps.HasCapability(UDPConnection)).IsTrue() +}