1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-30 05:56:54 -05:00
v2fly/testing/unit/errorsubject.go

39 lines
930 B
Go
Raw Normal View History

2015-09-09 09:18:29 -04:00
package unit
type ErrorSubject struct {
*Subject
value error
}
func NewErrorSubject(base *Subject, value error) *ErrorSubject {
2015-09-09 09:19:46 -04:00
subject := new(ErrorSubject)
2015-09-09 09:18:29 -04:00
subject.Subject = base
subject.value = value
return subject
}
func (subject *ErrorSubject) Named(name string) *ErrorSubject {
subject.Subject.Named(name)
return subject
}
func (subject *ErrorSubject) Fail(verb string, other error) {
subject.FailWithMessage("Not true that " + subject.DisplayString() + " " + verb + " <" + other.Error() + ">.")
}
func (subject *ErrorSubject) DisplayString() string {
return subject.Subject.DisplayString(subject.value.Error())
}
func (subject *ErrorSubject) Equals(expectation error) {
if subject.value != expectation {
subject.Fail("is equal to", expectation)
}
}
func (subject *ErrorSubject) IsNil() {
2015-09-09 09:26:11 -04:00
if subject.value != nil {
subject.FailWithMessage("Not true that " + subject.DisplayString() + " is nil.")
}
}