예제 #1
0
func Test_BytesBox_Write(t *testing.T) {
	data := []byte{0x9f, 0x37, 0xe1, 0xe, 0x4, 0x74, 0x65, 0x73, 0x74, 0x0, 0x0, 0x0}
	i := builtin.NewBytes([]byte("test"))

	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_BytesBoxRead(t *testing.T) {
	data := []byte{0x9f, 0x37, 0xe1, 0xe, 0x4, 0x74, 0x65, 0x73, 0x74, 0x0, 0x0, 0x0}
	val := builtin.NewBytes([]byte("test"))

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

	res := (&builtin.Bytes{}).Box()
	assert.NoError(t, res.Read(proto, nil, uuid.UUID{}))
	assert.Equal(t, val, res.Strip())
}
예제 #3
0
func Test_Bytes_Unwrap(t *testing.T) {
	i := builtin.NewBytes([]byte("test"))
	res := i.Strip().([]byte)
	assert.Equal(t, []byte("test"), res)
}