Beispiel #1
0
func TestStructScanWithoutConverstion(t *testing.T) {
	target := struct {
		Foo amf0.Bool
	}{}

	err := encoding.Unmarshal(bytes.NewBuffer([]byte{
		0x01, 0x01, // <bool>, <true>
	}), &target)

	assert.Nil(t, err)
	assert.Equal(t, amf0.Bool(true), target.Foo)
}
Beispiel #2
0
func TestSuccesfulEncodingWritesMarkerAndPayload(t *testing.T) {
	buf := new(bytes.Buffer)

	b := amf0.Bool(false)

	n, err := amf0.Encode(&b, buf)

	assert.Equal(t, 2, n)
	assert.Nil(t, err)

	assert.Equal(t, byte(0x1), buf.Bytes()[0],
		"amf0/encoder: did not write header byte")
	assert.Equal(t, byte(0x0), buf.Bytes()[1],
		"amf0/encoder: did not write type payload")
}