2018-11-03 08:03:02 -04:00
|
|
|
package serial_test
|
2018-11-02 10:01:33 -04:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"v2ray.com/core/common"
|
|
|
|
"v2ray.com/core/common/buf"
|
|
|
|
"v2ray.com/core/common/compare"
|
2018-11-03 08:03:02 -04:00
|
|
|
"v2ray.com/core/common/serial"
|
2018-11-02 10:01:33 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestUint32Serial(t *testing.T) {
|
|
|
|
b := buf.New()
|
|
|
|
defer b.Release()
|
|
|
|
|
2018-11-03 08:03:02 -04:00
|
|
|
n, err := serial.WriteUint32(b, 10)
|
2018-11-02 10:01:33 -04:00
|
|
|
common.Must(err)
|
|
|
|
if n != 4 {
|
|
|
|
t.Error("expect 4 bytes writtng, but actually ", n)
|
|
|
|
}
|
|
|
|
if err := compare.BytesEqualWithDetail(b.Bytes(), []byte{0, 0, 0, 10}); err != nil {
|
|
|
|
t.Error(err)
|
|
|
|
}
|
|
|
|
}
|