1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-10-03 09:16:14 -04:00
v2fly/testing/unit/errorsubject.go
2015-09-20 13:08:05 +02:00

39 lines
898 B
Go

package unit
type ErrorSubject struct {
*Subject
value error
}
func NewErrorSubject(base *Subject, value error) *ErrorSubject {
return &ErrorSubject{
Subject: base,
value: value,
}
}
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() {
if subject.value != nil {
subject.FailWithMessage("Not true that " + subject.DisplayString() + " is nil.")
}
}