1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-07-02 03:55:24 +00:00
v2fly/common/serial/serial_test.go

26 lines
451 B
Go
Raw Normal View History

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