stringsubject.go 691 B

1234567891011121314151617181920212223242526272829
  1. package assert
  2. func String(value string) *StringSubject {
  3. return &StringSubject{value: value}
  4. }
  5. type StringSubject struct {
  6. Subject
  7. value string
  8. }
  9. func (subject *StringSubject) Named(name string) *StringSubject {
  10. subject.Subject.Named(name)
  11. return subject
  12. }
  13. func (subject *StringSubject) Fail(verb string, other string) {
  14. subject.FailWithMessage("Not true that " + subject.DisplayString() + " " + verb + " <" + other + ">.")
  15. }
  16. func (subject *StringSubject) DisplayString() string {
  17. return subject.Subject.DisplayString(subject.value)
  18. }
  19. func (subject *StringSubject) Equals(expectation string) {
  20. if subject.value != expectation {
  21. subject.Fail("is equal to", expectation)
  22. }
  23. }