2015-12-02 14:27:18 +00:00
|
|
|
package assert
|
|
|
|
|
|
|
|
type Subject struct {
|
2016-05-24 19:55:46 +00:00
|
|
|
disp string
|
|
|
|
a *Assert
|
2015-12-02 14:27:18 +00:00
|
|
|
}
|
|
|
|
|
2016-05-24 19:55:46 +00:00
|
|
|
func (subject *Subject) Fail(verb string, other string) {
|
|
|
|
subject.FailWithMessage("Not true that " + subject.DisplayString() + " " + verb + " <" + other + ">.")
|
2015-12-02 15:19:39 +00:00
|
|
|
}
|
|
|
|
|
2015-12-02 14:27:18 +00:00
|
|
|
func (subject *Subject) FailWithMessage(message string) {
|
2016-05-24 19:55:46 +00:00
|
|
|
subject.a.Fail(message)
|
2015-12-02 14:27:18 +00:00
|
|
|
}
|
|
|
|
|
2016-05-24 19:55:46 +00:00
|
|
|
func (subject *Subject) DisplayString() string {
|
|
|
|
value := subject.disp
|
2015-12-02 14:27:18 +00:00
|
|
|
if len(value) == 0 {
|
|
|
|
value = "unknown"
|
|
|
|
}
|
2016-05-24 19:55:46 +00:00
|
|
|
return "<" + value + ">"
|
2015-12-02 14:27:18 +00:00
|
|
|
}
|