assertions.go 889 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package unit
  2. import (
  3. "testing"
  4. )
  5. // Assertion is an assertion library inspired by Truth.
  6. // See http://google.github.io/truth/
  7. type Assertion struct {
  8. t *testing.T
  9. }
  10. func Assert(t *testing.T) *Assertion {
  11. assert := new(Assertion)
  12. assert.t = t
  13. return assert
  14. }
  15. func (a *Assertion) Int(value int) *IntSubject {
  16. return NewIntSubject(NewSubject(a), value)
  17. }
  18. func (a *Assertion) Uint16(value uint16) *Uint16Subject {
  19. return NewUint16Subject(NewSubject(a), value)
  20. }
  21. func (a *Assertion) Byte(value byte) *ByteSubject {
  22. return NewByteSubject(NewSubject(a), value)
  23. }
  24. func (a *Assertion) Bytes(value []byte) *BytesSubject {
  25. return NewBytesSubject(NewSubject(a), value)
  26. }
  27. func (a *Assertion) String(value string) *StringSubject {
  28. return NewStringSubject(NewSubject(a), value)
  29. }
  30. func (a *Assertion) Error(value error) *ErrorSubject {
  31. return NewErrorSubject(NewSubject(a), value)
  32. }