byte.go 786 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package assert
  2. import (
  3. "v2ray.com/core/common/serial"
  4. )
  5. func (this *Assert) Byte(value byte) *ByteSubject {
  6. return &ByteSubject{
  7. Subject: Subject{
  8. disp: serial.ByteToHexString(value),
  9. a: this,
  10. },
  11. value: value,
  12. }
  13. }
  14. type ByteSubject struct {
  15. Subject
  16. value byte
  17. }
  18. func (subject *ByteSubject) Equals(expectation byte) {
  19. if subject.value != expectation {
  20. subject.Fail("is equal to", serial.ByteToHexString(expectation))
  21. }
  22. }
  23. func (subject *ByteSubject) GreaterThan(expectation byte) {
  24. if subject.value <= expectation {
  25. subject.Fail("is greater than", serial.ByteToHexString(expectation))
  26. }
  27. }
  28. func (subject *ByteSubject) LessThan(expectation byte) {
  29. if subject.value >= expectation {
  30. subject.Fail("is less than", serial.ByteToHexString(expectation))
  31. }
  32. }