1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-21 09:36:34 -05:00

more update

This commit is contained in:
Darien Raymond 2015-12-02 16:27:55 +00:00
parent ec31c1fa7f
commit fa7c1069bc
13 changed files with 67 additions and 17 deletions

View File

@ -41,7 +41,7 @@ func TestIPv6Address(t *testing.T) {
v2netassert.Address(addr).IsNotIPv4()
v2netassert.Address(addr).IsNotDomain()
assert.Bytes(addr.IP()).Equals(ip)
assert.Uint16(addr.Port().Value()).Equals(port.Value())
v2netassert.Port(addr.Port()).Equals(port)
assert.String(addr).Equals("[102:304:102:304:102:304:102:304]:443")
}
@ -56,7 +56,7 @@ func TestDomainAddress(t *testing.T) {
v2netassert.Address(addr).IsNotIPv6()
v2netassert.Address(addr).IsNotIPv4()
assert.StringLiteral(addr.Domain()).Equals(domain)
assert.Uint16(addr.Port().Value()).Equals(port.Value())
v2netassert.Port(addr.Port()).Equals(port)
assert.String(addr).Equals("v2ray.com:443")
}

View File

@ -4,6 +4,7 @@ import (
"testing"
v2net "github.com/v2ray/v2ray-core/common/net"
v2netassert "github.com/v2ray/v2ray-core/common/net/testing/assert"
v2testing "github.com/v2ray/v2ray-core/testing"
"github.com/v2ray/v2ray-core/testing/assert"
)
@ -12,8 +13,8 @@ func TestTCPDestination(t *testing.T) {
v2testing.Current(t)
dest := v2net.NewTCPDestination(v2net.IPAddress([]byte{1, 2, 3, 4}, 80))
assert.Bool(dest.IsTCP()).IsTrue()
assert.Bool(dest.IsUDP()).IsFalse()
v2netassert.Destination(dest).IsTCP()
v2netassert.Destination(dest).IsNotUDP()
assert.String(dest).Equals("tcp:1.2.3.4:80")
}
@ -21,7 +22,7 @@ func TestUDPDestination(t *testing.T) {
v2testing.Current(t)
dest := v2net.NewUDPDestination(v2net.IPAddress([]byte{0x20, 0x01, 0x48, 0x60, 0x48, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x88}, 53))
assert.Bool(dest.IsTCP()).IsFalse()
assert.Bool(dest.IsUDP()).IsTrue()
v2netassert.Destination(dest).IsNotTCP()
v2netassert.Destination(dest).IsUDP()
assert.String(dest).Equals("udp:[2001:4860:4860::8888]:53")
}

View File

@ -1,4 +1,4 @@
package unit
package assert
import (
v2net "github.com/v2ray/v2ray-core/common/net"

View File

@ -0,0 +1,49 @@
package assert
import (
v2net "github.com/v2ray/v2ray-core/common/net"
"github.com/v2ray/v2ray-core/common/serial"
"github.com/v2ray/v2ray-core/testing/assert"
)
func Destination(value v2net.Destination) *DestinationSubject {
return &DestinationSubject{value: value}
}
type DestinationSubject struct {
*assert.Subject
value v2net.Destination
}
func (this *DestinationSubject) Named(name string) *DestinationSubject {
this.Subject.Named(name)
return this
}
func (this *DestinationSubject) DisplayString() string {
return this.Subject.DisplayString(this.value.String())
}
func (this *DestinationSubject) IsTCP() {
if !this.value.IsTCP() {
this.Fail(this.DisplayString(), "is", serial.StringLiteral("a TCP destination"))
}
}
func (this *DestinationSubject) IsNotTCP() {
if this.value.IsTCP() {
this.Fail(this.DisplayString(), "is not", serial.StringLiteral("a TCP destination"))
}
}
func (this *DestinationSubject) IsUDP() {
if !this.value.IsUDP() {
this.Fail(this.DisplayString(), "is", serial.StringLiteral("a UDP destination"))
}
}
func (this *DestinationSubject) IsNotUDP() {
if this.value.IsUDP() {
this.Fail(this.DisplayString(), "is not", serial.StringLiteral("a UDP destination"))
}
}

View File

@ -1,4 +1,4 @@
package unit
package assert
import (
v2net "github.com/v2ray/v2ray-core/common/net"

View File

@ -3,7 +3,7 @@ package protocol
import (
"testing"
v2testing "github.com/v2ray/v2ray-core/testing"
v2testing "github.com/v2ray/v2ray-core/testing"
"github.com/v2ray/v2ray-core/testing/assert"
"github.com/v2ray/v2ray-core/transport"
)

View File

@ -3,7 +3,7 @@ package config
import (
"testing"
v2testing "github.com/v2ray/v2ray-core/testing"
v2testing "github.com/v2ray/v2ray-core/testing"
"github.com/v2ray/v2ray-core/testing/assert"
)

View File

@ -4,7 +4,7 @@ import (
"testing"
"time"
v2testing "github.com/v2ray/v2ray-core/testing"
v2testing "github.com/v2ray/v2ray-core/testing"
"github.com/v2ray/v2ray-core/testing/assert"
)

View File

@ -1,11 +1,11 @@
package assert
import (
"github.com/v2ray/v2ray-core/common/serial"
"github.com/v2ray/v2ray-core/common/serial"
)
func StringLiteral(value string) *StringSubject {
return String(serial.StringLiteral((value)))
return String(serial.StringLiteral((value)))
}
func String(value serial.String) *StringSubject {

View File

@ -6,7 +6,7 @@ import (
"path/filepath"
"testing"
v2testing "github.com/v2ray/v2ray-core/testing"
v2testing "github.com/v2ray/v2ray-core/testing"
"github.com/v2ray/v2ray-core/testing/assert"
)

View File

@ -3,7 +3,7 @@ package main
import (
"testing"
v2testing "github.com/v2ray/v2ray-core/testing"
v2testing "github.com/v2ray/v2ray-core/testing"
"github.com/v2ray/v2ray-core/testing/assert"
)

View File

@ -11,7 +11,7 @@ import (
"testing"
"time"
v2testing "github.com/v2ray/v2ray-core/testing"
v2testing "github.com/v2ray/v2ray-core/testing"
"github.com/v2ray/v2ray-core/testing/assert"
)

View File

@ -3,7 +3,7 @@ package git
import (
"testing"
v2testing "github.com/v2ray/v2ray-core/testing"
v2testing "github.com/v2ray/v2ray-core/testing"
"github.com/v2ray/v2ray-core/testing/assert"
)