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

simplify testing

This commit is contained in:
v2ray
2016-05-24 21:55:46 +02:00
parent 3582b9d869
commit fc63f0432c
99 changed files with 726 additions and 817 deletions

View File

@@ -3,12 +3,16 @@ package assert
import (
"bytes"
"net"
"github.com/v2ray/v2ray-core/common/serial"
)
func IP(value net.IP) *IPSubject {
return &IPSubject{value: value}
func (this *Assert) IP(value net.IP) *IPSubject {
return &IPSubject{
Subject: Subject{
a: this,
disp: value.String(),
},
value: value,
}
}
type IPSubject struct {
@@ -16,23 +20,14 @@ type IPSubject struct {
value net.IP
}
func (subject *IPSubject) Named(name string) *IPSubject {
subject.Subject.Named(name)
return subject
}
func (subject *IPSubject) DisplayString() string {
return subject.Subject.DisplayString(subject.value.String())
}
func (subject *IPSubject) IsNil() {
if subject.value != nil {
subject.Fail(subject.DisplayString(), "is", serial.StringT("nil"))
subject.Fail("is", "nil")
}
}
func (subject *IPSubject) Equals(ip net.IP) {
if !bytes.Equal([]byte(subject.value), []byte(ip)) {
subject.Fail(subject.DisplayString(), "equals to", ip)
subject.Fail("equals to", ip.String())
}
}