mirror of
https://github.com/v2fly/v2ray-core
synced 2024-02-27 03:18:06 +00:00
typed segments
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package assert
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
|
||||
"github.com/v2ray/v2ray-core/common/serial"
|
||||
)
|
||||
|
||||
@@ -26,7 +28,15 @@ func (subject *PointerSubject) Equals(expectation interface{}) {
|
||||
}
|
||||
|
||||
func (subject *PointerSubject) IsNil() {
|
||||
if subject.value != nil {
|
||||
if subject.value == nil {
|
||||
return
|
||||
}
|
||||
|
||||
valueType := reflect.TypeOf(subject.value)
|
||||
nilType := reflect.Zero(valueType)
|
||||
realValue := reflect.ValueOf(subject.value)
|
||||
|
||||
if nilType != realValue {
|
||||
subject.Fail("is", "nil")
|
||||
}
|
||||
}
|
||||
@@ -35,4 +45,12 @@ func (subject *PointerSubject) IsNotNil() {
|
||||
if subject.value == nil {
|
||||
subject.Fail("is not", "nil")
|
||||
}
|
||||
|
||||
valueType := reflect.TypeOf(subject.value)
|
||||
nilType := reflect.Zero(valueType)
|
||||
realValue := reflect.ValueOf(subject.value)
|
||||
|
||||
if nilType == realValue {
|
||||
subject.Fail("is not", "nil")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user