mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-22 01:57:12 -05:00
39 lines
641 B
Go
39 lines
641 B
Go
package assert
|
|
|
|
func (v *Assert) Error(value error) *ErrorSubject {
|
|
valueStr := ""
|
|
if value != nil {
|
|
valueStr = value.Error()
|
|
}
|
|
return &ErrorSubject{
|
|
Subject: Subject{
|
|
a: v,
|
|
disp: valueStr,
|
|
},
|
|
value: value,
|
|
}
|
|
}
|
|
|
|
type ErrorSubject struct {
|
|
Subject
|
|
value error
|
|
}
|
|
|
|
func (subject *ErrorSubject) Equals(expectation error) {
|
|
if subject.value != expectation {
|
|
subject.Fail("is equal to", expectation.Error())
|
|
}
|
|
}
|
|
|
|
func (subject *ErrorSubject) IsNil() {
|
|
if subject.value != nil {
|
|
subject.Fail("is", "nil")
|
|
}
|
|
}
|
|
|
|
func (subject *ErrorSubject) IsNotNil() {
|
|
if subject.value == nil {
|
|
subject.Fail("is not", "nil")
|
|
}
|
|
}
|