mirror of
https://github.com/v2fly/v2ray-core.git
synced 2026-05-21 19:59:08 -04:00
rename 'this'
This commit is contained in:
@@ -4,11 +4,11 @@ import (
|
||||
v2net "v2ray.com/core/common/net"
|
||||
)
|
||||
|
||||
func (this *Assert) Address(value v2net.Address) *AddressSubject {
|
||||
func (v *Assert) Address(value v2net.Address) *AddressSubject {
|
||||
return &AddressSubject{
|
||||
Subject: Subject{
|
||||
disp: value.String(),
|
||||
a: this,
|
||||
a: v,
|
||||
},
|
||||
value: value,
|
||||
}
|
||||
|
||||
@@ -18,9 +18,9 @@ type Assert struct {
|
||||
t *testing.T
|
||||
}
|
||||
|
||||
func (this *Assert) Fail(message string) {
|
||||
func (v *Assert) Fail(message string) {
|
||||
fmt.Println(decorate(message))
|
||||
this.t.Fail()
|
||||
v.t.Fail()
|
||||
}
|
||||
|
||||
func getCaller() (string, int) {
|
||||
|
||||
@@ -5,11 +5,11 @@ import (
|
||||
)
|
||||
|
||||
// Assert on a boolean variable.
|
||||
func (this *Assert) Bool(value bool) *BoolSubject {
|
||||
func (v *Assert) Bool(value bool) *BoolSubject {
|
||||
return &BoolSubject{
|
||||
Subject: Subject{
|
||||
disp: strconv.FormatBool(value),
|
||||
a: this,
|
||||
a: v,
|
||||
},
|
||||
value: value,
|
||||
}
|
||||
|
||||
@@ -4,11 +4,11 @@ import (
|
||||
"v2ray.com/core/common/serial"
|
||||
)
|
||||
|
||||
func (this *Assert) Byte(value byte) *ByteSubject {
|
||||
func (v *Assert) Byte(value byte) *ByteSubject {
|
||||
return &ByteSubject{
|
||||
Subject: Subject{
|
||||
disp: serial.ByteToHexString(value),
|
||||
a: this,
|
||||
a: v,
|
||||
},
|
||||
value: value,
|
||||
}
|
||||
|
||||
@@ -6,11 +6,11 @@ import (
|
||||
"v2ray.com/core/common/serial"
|
||||
)
|
||||
|
||||
func (this *Assert) Bytes(value []byte) *BytesSubject {
|
||||
func (v *Assert) Bytes(value []byte) *BytesSubject {
|
||||
return &BytesSubject{
|
||||
Subject: Subject{
|
||||
disp: serial.BytesToHexString(value),
|
||||
a: this,
|
||||
a: v,
|
||||
},
|
||||
value: value,
|
||||
}
|
||||
|
||||
@@ -4,11 +4,11 @@ import (
|
||||
v2net "v2ray.com/core/common/net"
|
||||
)
|
||||
|
||||
func (this *Assert) Destination(value v2net.Destination) *DestinationSubject {
|
||||
func (v *Assert) Destination(value v2net.Destination) *DestinationSubject {
|
||||
return &DestinationSubject{
|
||||
Subject: Subject{
|
||||
disp: value.String(),
|
||||
a: this,
|
||||
a: v,
|
||||
},
|
||||
value: value,
|
||||
}
|
||||
@@ -19,40 +19,40 @@ type DestinationSubject struct {
|
||||
value v2net.Destination
|
||||
}
|
||||
|
||||
func (this *DestinationSubject) IsTCP() {
|
||||
if this.value.Network != v2net.Network_TCP {
|
||||
this.Fail("is", "a TCP destination")
|
||||
func (v *DestinationSubject) IsTCP() {
|
||||
if v.value.Network != v2net.Network_TCP {
|
||||
v.Fail("is", "a TCP destination")
|
||||
}
|
||||
}
|
||||
|
||||
func (this *DestinationSubject) IsNotTCP() {
|
||||
if this.value.Network == v2net.Network_TCP {
|
||||
this.Fail("is not", "a TCP destination")
|
||||
func (v *DestinationSubject) IsNotTCP() {
|
||||
if v.value.Network == v2net.Network_TCP {
|
||||
v.Fail("is not", "a TCP destination")
|
||||
}
|
||||
}
|
||||
|
||||
func (this *DestinationSubject) IsUDP() {
|
||||
if this.value.Network != v2net.Network_UDP {
|
||||
this.Fail("is", "a UDP destination")
|
||||
func (v *DestinationSubject) IsUDP() {
|
||||
if v.value.Network != v2net.Network_UDP {
|
||||
v.Fail("is", "a UDP destination")
|
||||
}
|
||||
}
|
||||
|
||||
func (this *DestinationSubject) IsNotUDP() {
|
||||
if this.value.Network == v2net.Network_UDP {
|
||||
this.Fail("is not", "a UDP destination")
|
||||
func (v *DestinationSubject) IsNotUDP() {
|
||||
if v.value.Network == v2net.Network_UDP {
|
||||
v.Fail("is not", "a UDP destination")
|
||||
}
|
||||
}
|
||||
|
||||
func (this *DestinationSubject) EqualsString(another string) {
|
||||
if this.value.String() != another {
|
||||
this.Fail("not equals to string", another)
|
||||
func (v *DestinationSubject) EqualsString(another string) {
|
||||
if v.value.String() != another {
|
||||
v.Fail("not equals to string", another)
|
||||
}
|
||||
}
|
||||
|
||||
func (this *DestinationSubject) HasAddress() *AddressSubject {
|
||||
return this.a.Address(this.value.Address)
|
||||
func (v *DestinationSubject) HasAddress() *AddressSubject {
|
||||
return v.a.Address(v.value.Address)
|
||||
}
|
||||
|
||||
func (this *DestinationSubject) HasPort() *PortSubject {
|
||||
return this.a.Port(this.value.Port)
|
||||
func (v *DestinationSubject) HasPort() *PortSubject {
|
||||
return v.a.Port(v.value.Port)
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package assert
|
||||
|
||||
func (this *Assert) Error(value error) *ErrorSubject {
|
||||
func (v *Assert) Error(value error) *ErrorSubject {
|
||||
valueStr := ""
|
||||
if value != nil {
|
||||
valueStr = value.Error()
|
||||
}
|
||||
return &ErrorSubject{
|
||||
Subject: Subject{
|
||||
a: this,
|
||||
a: v,
|
||||
disp: valueStr,
|
||||
},
|
||||
value: value,
|
||||
|
||||
@@ -4,10 +4,10 @@ import (
|
||||
"v2ray.com/core/common/serial"
|
||||
)
|
||||
|
||||
func (this *Assert) Int64(value int64) *Int64Subject {
|
||||
func (v *Assert) Int64(value int64) *Int64Subject {
|
||||
return &Int64Subject{
|
||||
Subject: Subject{
|
||||
a: this,
|
||||
a: v,
|
||||
disp: serial.Int64ToString(value),
|
||||
},
|
||||
value: value,
|
||||
|
||||
@@ -4,10 +4,10 @@ import (
|
||||
"v2ray.com/core/common/serial"
|
||||
)
|
||||
|
||||
func (this *Assert) Int(value int) *IntSubject {
|
||||
func (v *Assert) Int(value int) *IntSubject {
|
||||
return &IntSubject{
|
||||
Subject: Subject{
|
||||
a: this,
|
||||
a: v,
|
||||
disp: serial.IntToString(value),
|
||||
},
|
||||
value: value,
|
||||
|
||||
@@ -5,10 +5,10 @@ import (
|
||||
"net"
|
||||
)
|
||||
|
||||
func (this *Assert) IP(value net.IP) *IPSubject {
|
||||
func (v *Assert) IP(value net.IP) *IPSubject {
|
||||
return &IPSubject{
|
||||
Subject: Subject{
|
||||
a: this,
|
||||
a: v,
|
||||
disp: value.String(),
|
||||
},
|
||||
value: value,
|
||||
|
||||
@@ -6,10 +6,10 @@ import (
|
||||
"v2ray.com/core/common/serial"
|
||||
)
|
||||
|
||||
func (this *Assert) Pointer(value interface{}) *PointerSubject {
|
||||
func (v *Assert) Pointer(value interface{}) *PointerSubject {
|
||||
return &PointerSubject{
|
||||
Subject: Subject{
|
||||
a: this,
|
||||
a: v,
|
||||
disp: serial.PointerToString(value),
|
||||
},
|
||||
value: value,
|
||||
|
||||
@@ -4,10 +4,10 @@ import (
|
||||
v2net "v2ray.com/core/common/net"
|
||||
)
|
||||
|
||||
func (this *Assert) Port(value v2net.Port) *PortSubject {
|
||||
func (v *Assert) Port(value v2net.Port) *PortSubject {
|
||||
return &PortSubject{
|
||||
Subject: Subject{
|
||||
a: this,
|
||||
a: v,
|
||||
disp: value.String(),
|
||||
},
|
||||
value: value,
|
||||
|
||||
@@ -4,10 +4,10 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
func (this *Assert) String(value string) *StringSubject {
|
||||
func (v *Assert) String(value string) *StringSubject {
|
||||
return &StringSubject{
|
||||
Subject: Subject{
|
||||
a: this,
|
||||
a: v,
|
||||
disp: value,
|
||||
},
|
||||
value: value,
|
||||
|
||||
@@ -4,10 +4,10 @@ import (
|
||||
"v2ray.com/core/common/serial"
|
||||
)
|
||||
|
||||
func (this *Assert) Uint16(value uint16) *Uint16Subject {
|
||||
func (v *Assert) Uint16(value uint16) *Uint16Subject {
|
||||
return &Uint16Subject{
|
||||
Subject: Subject{
|
||||
a: this,
|
||||
a: v,
|
||||
disp: serial.Uint16ToString(value),
|
||||
},
|
||||
value: value,
|
||||
|
||||
@@ -4,10 +4,10 @@ import (
|
||||
"v2ray.com/core/common/serial"
|
||||
)
|
||||
|
||||
func (this *Assert) Uint32(value uint32) *Uint32Subject {
|
||||
func (v *Assert) Uint32(value uint32) *Uint32Subject {
|
||||
return &Uint32Subject{
|
||||
Subject: Subject{
|
||||
a: this,
|
||||
a: v,
|
||||
disp: serial.Uint32ToString(value),
|
||||
},
|
||||
value: value,
|
||||
|
||||
@@ -31,6 +31,6 @@ func (server *Server) Start() (v2net.Destination, error) {
|
||||
return v2net.TCPDestination(v2net.LocalHostIP, v2net.Port(server.Port)), nil
|
||||
}
|
||||
|
||||
func (this *Server) Close() {
|
||||
this.accepting = false
|
||||
func (v *Server) Close() {
|
||||
v.accepting = false
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ func (server *Server) handleConnection(conn net.Conn) {
|
||||
conn.Close()
|
||||
}
|
||||
|
||||
func (this *Server) Close() {
|
||||
this.accepting = false
|
||||
this.listener.Close()
|
||||
func (v *Server) Close() {
|
||||
v.accepting = false
|
||||
v.listener.Close()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user