bytes.go 668 B

12345678910111213141516171819202122232425262728293031323334
  1. package assert
  2. import (
  3. "bytes"
  4. "v2ray.com/core/common/serial"
  5. )
  6. func (this *Assert) Bytes(value []byte) *BytesSubject {
  7. return &BytesSubject{
  8. Subject: Subject{
  9. disp: serial.BytesToHexString(value),
  10. a: this,
  11. },
  12. value: value,
  13. }
  14. }
  15. type BytesSubject struct {
  16. Subject
  17. value []byte
  18. }
  19. func (subject *BytesSubject) Equals(expectation []byte) {
  20. if !bytes.Equal(subject.value, expectation) {
  21. subject.Fail("is equal to", serial.BytesToHexString(expectation))
  22. }
  23. }
  24. func (subject *BytesSubject) NotEquals(expectation []byte) {
  25. if bytes.Equal(subject.value, expectation) {
  26. subject.Fail("is not equal to", serial.BytesToHexString(expectation))
  27. }
  28. }