示例#1
0
func Test_IntBox_Write(t *testing.T) {
	data := []byte{0xda, 0x9b, 0x50, 0xa8, 0xda, 0xbc, 0x34, 0x13}
	i := builtin.NewInt(322223322)

	var buff = new(bytes.Buffer)
	proto := bin.NewEncoder(buff)

	assert.NoError(t, i.Box().Write(proto))
	assert.Equal(t, data, buff.Bytes())
}
示例#2
0
func Test_IntBoxRead(t *testing.T) {
	data := []byte{0xda, 0x9b, 0x50, 0xa8, 0xda, 0xbc, 0x34, 0x13}
	val := builtin.NewInt(322223322)

	proto := bin.NewDecoder(bytes.NewBuffer(data))

	res := (&builtin.Int{}).Box()
	assert.NoError(t, res.Read(proto, nil, uuid.UUID{}))
	assert.Equal(t, val, res.Strip())
}
示例#3
0
func Test_Int_Value(t *testing.T) {
	i := builtin.NewInt(322223322)
	res := i.Strip()
	assert.Equal(t, int32(322223322), res)
}