serial_test.go 469 B

123456789101112131415161718192021222324
  1. package serial_test
  2. import (
  3. "testing"
  4. "v2ray.com/core/common"
  5. "v2ray.com/core/common/buf"
  6. "v2ray.com/core/common/compare"
  7. "v2ray.com/core/common/serial"
  8. )
  9. func TestUint32Serial(t *testing.T) {
  10. b := buf.New()
  11. defer b.Release()
  12. n, err := serial.WriteUint32(b, 10)
  13. common.Must(err)
  14. if n != 4 {
  15. t.Error("expect 4 bytes writtng, but actually ", n)
  16. }
  17. if err := compare.BytesEqualWithDetail(b.Bytes(), []byte{0, 0, 0, 10}); err != nil {
  18. t.Error(err)
  19. }
  20. }