Ejemplo n.º 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())
}
Ejemplo n.º 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())
}
Ejemplo n.º 3
0
func Test_Int_Value(t *testing.T) {
	i := builtin.NewInt(322223322)
	res := i.Strip()
	assert.Equal(t, int32(322223322), res)
}