You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
732 B

  1. package common
  2. import (
  3. "testing"
  4. "github.com/stretchr/testify/assert"
  5. )
  6. func TestPrefixEndBytes(t *testing.T) {
  7. assert := assert.New(t)
  8. var testCases = []struct {
  9. prefix []byte
  10. expected []byte
  11. }{
  12. {[]byte{byte(55), byte(255), byte(255), byte(0)}, []byte{byte(55), byte(255), byte(255), byte(1)}},
  13. {[]byte{byte(55), byte(255), byte(255), byte(15)}, []byte{byte(55), byte(255), byte(255), byte(16)}},
  14. {[]byte{byte(55), byte(200), byte(255)}, []byte{byte(55), byte(201)}},
  15. {[]byte{byte(55), byte(255), byte(255)}, []byte{byte(56)}},
  16. {[]byte{byte(255), byte(255), byte(255)}, nil},
  17. {nil, nil},
  18. }
  19. for _, test := range testCases {
  20. end := PrefixEndBytes(test.prefix)
  21. assert.Equal(test.expected, end)
  22. }
  23. }