test case for serial

pull/298/merge
Darien Raymond 8 years ago
parent 097cdf01d6
commit ff83a9ca91
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169

@ -24,3 +24,12 @@ func TestBytesToHex(t *testing.T) {
assert.String(test.output).Equals(BytesToHexString(test.input)) 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)
}

@ -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…
Cancel
Save