2016-05-24 15:55:46 -04:00
|
|
|
package assert
|
|
|
|
|
2016-11-27 15:39:09 -05:00
|
|
|
func (v *Assert) Error(value error) *ErrorSubject {
|
2016-05-24 15:55:46 -04:00
|
|
|
valueStr := ""
|
|
|
|
if value != nil {
|
|
|
|
valueStr = value.Error()
|
|
|
|
}
|
|
|
|
return &ErrorSubject{
|
|
|
|
Subject: Subject{
|
2016-11-27 15:39:09 -05:00
|
|
|
a: v,
|
2016-05-24 15:55:46 -04:00
|
|
|
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")
|
|
|
|
}
|
|
|
|
}
|