diff --git a/common/serial/bytes_test.go b/common/serial/bytes_test.go index 4b37a42e..a873395c 100644 --- a/common/serial/bytes_test.go +++ b/common/serial/bytes_test.go @@ -24,3 +24,12 @@ func TestBytesToHex(t *testing.T) { assert.String(test.output).Equals(BytesToHexString(test.input)) } } + +func TestInt64(t *testing.T) { + assert := assert.On(t) + + x := int64(375134875348) + b := Int64ToBytes(x, []byte{}) + v := BytesToInt64(b) + assert.Int64(x).Equals(v) +} diff --git a/common/serial/string_test.go b/common/serial/string_test.go new file mode 100644 index 00000000..9464df5b --- /dev/null +++ b/common/serial/string_test.go @@ -0,0 +1,20 @@ +package serial_test + +import ( + "testing" + + "v2ray.com/core/common" + "v2ray.com/core/common/buf" + . "v2ray.com/core/common/serial" + "v2ray.com/core/testing/assert" +) + +func TestUint32(t *testing.T) { + assert := assert.On(t) + + x := uint32(458634234) + s1 := Uint32ToBytes(x, []byte{}) + s2 := buf.New() + common.Must(s2.AppendSupplier(WriteUint32(x))) + assert.Bytes(s1).Equals(s2.Bytes()) +}