int64subject.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package assert
  2. import (
  3. "strconv"
  4. )
  5. func Int64(value int64) *Int64Subject {
  6. return &Int64Subject{value: value}
  7. }
  8. type Int64Subject struct {
  9. Subject
  10. value int64
  11. }
  12. func (subject *Int64Subject) Named(name string) *Int64Subject {
  13. subject.Subject.Named(name)
  14. return subject
  15. }
  16. func (subject *Int64Subject) Fail(verb string, other int64) {
  17. subject.FailWithMessage("Not true that " + subject.DisplayString() + " " + verb + " <" + strconv.FormatInt(other, 10) + ">.")
  18. }
  19. func (subject *Int64Subject) DisplayString() string {
  20. return subject.Subject.DisplayString(strconv.FormatInt(subject.value, 10))
  21. }
  22. func (subject *Int64Subject) Equals(expectation int64) {
  23. if subject.value != expectation {
  24. subject.Fail("is equal to", expectation)
  25. }
  26. }
  27. func (subject *Int64Subject) GreaterThan(expectation int64) {
  28. if subject.value <= expectation {
  29. subject.Fail("is greater than", expectation)
  30. }
  31. }
  32. func (subject *Int64Subject) AtMost(expectation int64) {
  33. if subject.value > expectation {
  34. subject.Fail("is at most", expectation)
  35. }
  36. }
  37. func (subject *Int64Subject) AtLeast(expectation int64) {
  38. if subject.value < expectation {
  39. subject.Fail("is at least", expectation)
  40. }
  41. }