mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-02 23:47:07 -05:00
test case for serial
This commit is contained in:
parent
097cdf01d6
commit
ff83a9ca91
@ -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)
|
||||
}
|
||||
|
20
common/serial/string_test.go
Normal file
20
common/serial/string_test.go
Normal file
@ -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())
|
||||
}
|
Loading…
Reference in New Issue
Block a user