1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2025-12-27 12:35: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

38
testing/assert/pointer.go Normal file
View File

@@ -0,0 +1,38 @@
package assert
import (
"github.com/v2ray/v2ray-core/common/serial"
)
func (this *Assert) Pointer(value interface{}) *PointerSubject {
return &PointerSubject{
Subject: Subject{
a: this,
disp: serial.PointerToString(value),
},
value: value,
}
}
type PointerSubject struct {
Subject
value interface{}
}
func (subject *PointerSubject) Equals(expectation interface{}) {
if subject.value != expectation {
subject.Fail("is equal to", serial.PointerToString(expectation))
}
}
func (subject *PointerSubject) IsNil() {
if subject.value != nil {
subject.Fail("is", "nil")
}
}
func (subject *PointerSubject) IsNotNil() {
if subject.value == nil {
subject.Fail("is not", "nil")
}
}