messages.go 6.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. package assertions
  2. const ( // equality
  3. shouldHaveBeenEqual = "Expected: '%v'\nActual: '%v'\n(Should be equal)"
  4. shouldNotHaveBeenEqual = "Expected '%v'\nto NOT equal '%v'\n(but it did)!"
  5. shouldHaveBeenEqualTypeMismatch = "Expected: '%v' (%T)\nActual: '%v' (%T)\n(Should be equal, type mismatch)"
  6. shouldHaveBeenAlmostEqual = "Expected '%v' to almost equal '%v' (but it didn't)!"
  7. shouldHaveNotBeenAlmostEqual = "Expected '%v' to NOT almost equal '%v' (but it did)!"
  8. shouldHaveResembled = "Expected: '%#v'\nActual: '%#v'\n(Should resemble)!"
  9. shouldHaveResembledTypeMismatch = "Expected: '%#v' (%T)\nActual: '%#v' (%T)\n(Should resemble, type mismatch)"
  10. shouldNotHaveResembled = "Expected '%#v'\nto NOT resemble '%#v'\n(but it did)!"
  11. shouldBePointers = "Both arguments should be pointers "
  12. shouldHaveBeenNonNilPointer = shouldBePointers + "(the %s was %s)!"
  13. shouldHavePointedTo = "Expected '%+v' (address: '%v') and '%+v' (address: '%v') to be the same address (but their weren't)!"
  14. shouldNotHavePointedTo = "Expected '%+v' and '%+v' to be different references (but they matched: '%v')!"
  15. shouldHaveBeenNil = "Expected: nil\nActual: '%v'"
  16. shouldNotHaveBeenNil = "Expected '%+v' to NOT be nil (but it was)!"
  17. shouldHaveBeenTrue = "Expected: true\nActual: %v"
  18. shouldHaveBeenFalse = "Expected: false\nActual: %v"
  19. shouldHaveBeenZeroValue = "'%+v' should have been the zero value" //"Expected: (zero value)\nActual: %v"
  20. )
  21. const ( // quantity comparisons
  22. shouldHaveBeenGreater = "Expected '%v' to be greater than '%v' (but it wasn't)!"
  23. shouldHaveBeenGreaterOrEqual = "Expected '%v' to be greater than or equal to '%v' (but it wasn't)!"
  24. shouldHaveBeenLess = "Expected '%v' to be less than '%v' (but it wasn't)!"
  25. shouldHaveBeenLessOrEqual = "Expected '%v' to be less than or equal to '%v' (but it wasn't)!"
  26. shouldHaveBeenBetween = "Expected '%v' to be between '%v' and '%v' (but it wasn't)!"
  27. shouldNotHaveBeenBetween = "Expected '%v' NOT to be between '%v' and '%v' (but it was)!"
  28. shouldHaveDifferentUpperAndLower = "The lower and upper bounds must be different values (they were both '%v')."
  29. shouldHaveBeenBetweenOrEqual = "Expected '%v' to be between '%v' and '%v' or equal to one of them (but it wasn't)!"
  30. shouldNotHaveBeenBetweenOrEqual = "Expected '%v' NOT to be between '%v' and '%v' or equal to one of them (but it was)!"
  31. )
  32. const ( // collections
  33. shouldHaveContained = "Expected the container (%v) to contain: '%v' (but it didn't)!"
  34. shouldNotHaveContained = "Expected the container (%v) NOT to contain: '%v' (but it did)!"
  35. shouldHaveContainedKey = "Expected the %v to contain the key: %v (but it didn't)!"
  36. shouldNotHaveContainedKey = "Expected the %v NOT to contain the key: %v (but it did)!"
  37. shouldHaveBeenIn = "Expected '%v' to be in the container (%v), but it wasn't!"
  38. shouldNotHaveBeenIn = "Expected '%v' NOT to be in the container (%v), but it was!"
  39. shouldHaveBeenAValidCollection = "You must provide a valid container (was %v)!"
  40. shouldHaveBeenAValidMap = "You must provide a valid map type (was %v)!"
  41. shouldHaveBeenEmpty = "Expected %+v to be empty (but it wasn't)!"
  42. shouldNotHaveBeenEmpty = "Expected %+v to NOT be empty (but it was)!"
  43. shouldHaveBeenAValidInteger = "You must provide a valid integer (was %v)!"
  44. shouldHaveBeenAValidLength = "You must provide a valid positive integer (was %v)!"
  45. shouldHaveHadLength = "Expected %+v (length: %v) to have length equal to '%v', but it wasn't!"
  46. )
  47. const ( // strings
  48. shouldHaveStartedWith = "Expected '%v'\nto start with '%v'\n(but it didn't)!"
  49. shouldNotHaveStartedWith = "Expected '%v'\nNOT to start with '%v'\n(but it did)!"
  50. shouldHaveEndedWith = "Expected '%v'\nto end with '%v'\n(but it didn't)!"
  51. shouldNotHaveEndedWith = "Expected '%v'\nNOT to end with '%v'\n(but it did)!"
  52. shouldAllBeStrings = "All arguments to this assertion must be strings (you provided: %v)."
  53. shouldBothBeStrings = "Both arguments to this assertion must be strings (you provided %v and %v)."
  54. shouldBeString = "The argument to this assertion must be a string (you provided %v)."
  55. shouldHaveContainedSubstring = "Expected '%s' to contain substring '%s' (but it didn't)!"
  56. shouldNotHaveContainedSubstring = "Expected '%s' NOT to contain substring '%s' (but it did)!"
  57. shouldHaveBeenBlank = "Expected '%s' to be blank (but it wasn't)!"
  58. shouldNotHaveBeenBlank = "Expected value to NOT be blank (but it was)!"
  59. )
  60. const ( // panics
  61. shouldUseVoidNiladicFunction = "You must provide a void, niladic function as the first argument!"
  62. shouldHavePanickedWith = "Expected func() to panic with '%v' (but it panicked with '%v')!"
  63. shouldHavePanicked = "Expected func() to panic (but it didn't)!"
  64. shouldNotHavePanicked = "Expected func() NOT to panic (error: '%+v')!"
  65. shouldNotHavePanickedWith = "Expected func() NOT to panic with '%v' (but it did)!"
  66. )
  67. const ( // type checking
  68. shouldHaveBeenA = "Expected '%v' to be: '%v' (but was: '%v')!"
  69. shouldNotHaveBeenA = "Expected '%v' to NOT be: '%v' (but it was)!"
  70. shouldHaveImplemented = "Expected: '%v interface support'\nActual: '%v' does not implement the interface!"
  71. shouldNotHaveImplemented = "Expected '%v'\nto NOT implement '%v'\n(but it did)!"
  72. shouldCompareWithInterfacePointer = "The expected value must be a pointer to an interface type (eg. *fmt.Stringer)"
  73. shouldNotBeNilActual = "The actual value was 'nil' and should be a value or a pointer to a value!"
  74. )
  75. const ( // time comparisons
  76. shouldUseTimes = "You must provide time instances as arguments to this assertion."
  77. shouldUseTimeSlice = "You must provide a slice of time instances as the first argument to this assertion."
  78. shouldUseDurationAndTime = "You must provide a duration and a time as arguments to this assertion."
  79. shouldHaveHappenedBefore = "Expected '%v' to happen before '%v' (it happened '%v' after)!"
  80. shouldHaveHappenedAfter = "Expected '%v' to happen after '%v' (it happened '%v' before)!"
  81. shouldHaveHappenedBetween = "Expected '%v' to happen between '%v' and '%v' (it happened '%v' outside threshold)!"
  82. shouldNotHaveHappenedOnOrBetween = "Expected '%v' to NOT happen on or between '%v' and '%v' (but it did)!"
  83. // format params: incorrect-index, previous-index, previous-time, incorrect-index, incorrect-time
  84. shouldHaveBeenChronological = "The 'Time' at index [%d] should have happened after the previous one (but it didn't!):\n [%d]: %s\n [%d]: %s (see, it happened before!)"
  85. )