@@ -128,7 +128,7 @@ func TestEncodeStructOther(t *testing.T) {
128128}
129129
130130func TestEncodeUnknownFields (t * testing.T ) {
131- type Msg1 struct { // without S0, I1
131+ type Msg1 struct {
132132 I0 int32 `thrift:"i0,2" frugal:"2,default,i32"`
133133 S1 string `thrift:"s1,4" frugal:"4,default,string"`
134134
@@ -145,6 +145,33 @@ func TestEncodeUnknownFields(t *testing.T) {
145145 assert .True (t , strings .Contains (string (b ), string (append ([]byte ("helloworld" )[:], byte (tSTOP )))))
146146}
147147
148+ func TestEncodeOnlyUnknownFields (t * testing.T ) {
149+ type Msg struct {
150+ _unknownFields []byte
151+ }
152+ m := & Msg {_unknownFields : []byte ("helloworld" )}
153+
154+ n := EncodedSize (m )
155+ b , err := Append (nil , m )
156+ assert .Nil (t , err )
157+ assert .Equal (t , n , len (b ))
158+ assert .BytesEqual (t , append ([]byte ("helloworld" ), byte (tSTOP )), b )
159+ }
160+
161+ func TestEncodeOnlyUnknownFieldsNamedType (t * testing.T ) {
162+ type UnknownFieldsType []byte
163+ type Msg struct {
164+ _unknownFields UnknownFieldsType
165+ }
166+ m := & Msg {_unknownFields : UnknownFieldsType ("helloworld" )}
167+
168+ n := EncodedSize (m )
169+ b , err := Append (nil , m )
170+ assert .Nil (t , err )
171+ assert .Equal (t , n , len (b ))
172+ assert .BytesEqual (t , append ([]byte ("helloworld" ), byte (tSTOP )), b )
173+ }
174+
148175func TestNestedListMapStruct (t * testing.T ) {
149176 type Msg1 struct {
150177 A string `frugal:"1,default,string"`
0 commit comments