6 qt "github.com/frankban/quicktest"
9 func TestBytesMarshalNil(t *testing.T) {
14 type structWithBytes struct {
19 func TestMarshalNilStructBytes(t *testing.T) {
20 _, err := Marshal(structWithBytes{B: Bytes("i42e")})
22 c.Assert(err, qt.IsNotNil)
25 type structWithOmitEmptyBytes struct {
26 A Bytes `bencode:",omitempty"`
27 B Bytes `bencode:",omitempty"`
30 func TestMarshalNilStructBytesOmitEmpty(t *testing.T) {
32 b, err := Marshal(structWithOmitEmptyBytes{B: Bytes("i42e")})
33 c.Assert(err, qt.IsNil)
36 err = Unmarshal(b, &s)
37 c.Assert(err, qt.IsNil)
38 c.Check(s.B, qt.DeepEquals, Bytes("i42e"))