v2ray-core/common/serial/serial_test.go

26 lines
451 B
Go
Raw Normal View History

2018-11-03 13:03:02 +01:00
package serial_test
2018-11-02 15:01:33 +01:00
import (
"testing"
2018-11-15 11:17:20 +01:00
"github.com/google/go-cmp/cmp"
2018-11-02 15:01:33 +01:00
"v2ray.com/core/common"
"v2ray.com/core/common/buf"
2018-11-03 13:03:02 +01:00
"v2ray.com/core/common/serial"
2018-11-02 15:01:33 +01:00
)
func TestUint32Serial(t *testing.T) {
b := buf.New()
defer b.Release()
2018-11-03 13:03:02 +01:00
n, err := serial.WriteUint32(b, 10)
2018-11-02 15:01:33 +01:00
common.Must(err)
if n != 4 {
t.Error("expect 4 bytes writtng, but actually ", n)
}
2018-11-15 11:17:20 +01:00
if diff := cmp.Diff(b.Bytes(), []byte{0, 0, 0, 10}); diff != "" {
t.Error(diff)
2018-11-02 15:01:33 +01:00
}
}