2015-09-09 08:51:26 -04:00
|
|
|
package unit
|
|
|
|
|
|
|
|
type Subject struct {
|
|
|
|
assert *Assertion
|
|
|
|
name string
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewSubject(assert *Assertion) *Subject {
|
2015-09-20 07:08:05 -04:00
|
|
|
return &Subject{
|
|
|
|
assert: assert,
|
|
|
|
name: "",
|
|
|
|
}
|
2015-09-09 08:51:26 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func (subject *Subject) FailWithMessage(message string) {
|
|
|
|
subject.assert.t.Error(message)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (subject *Subject) Named(name string) {
|
|
|
|
subject.name = name
|
|
|
|
}
|
|
|
|
|
|
|
|
func (subject *Subject) DisplayString(value string) string {
|
|
|
|
if len(value) == 0 {
|
|
|
|
value = "unknown"
|
|
|
|
}
|
|
|
|
if len(subject.name) == 0 {
|
|
|
|
return "<" + value + ">"
|
|
|
|
}
|
|
|
|
return subject.name + "(<" + value + ">)"
|
|
|
|
}
|