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) }
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") }