@@ -244,3 +244,32 @@ func TestMessageDecodingUnknownVersions(t *testing.T) {
244
244
t .Error ("Decoding an unknown magic byte produced an unknown error " , err )
245
245
}
246
246
}
247
+
248
+ func TestCompressionCodecUnmarshal (t * testing.T ) {
249
+ cases := []struct {
250
+ Input string
251
+ Expected CompressionCodec
252
+ ExpectedError bool
253
+ }{
254
+ {"none" , CompressionNone , false },
255
+ {"zstd" , CompressionZSTD , false },
256
+ {"gzip" , CompressionGZIP , false },
257
+ {"unknown" , CompressionNone , true },
258
+ }
259
+ for _ , c := range cases {
260
+ var cc CompressionCodec
261
+ err := cc .UnmarshalText ([]byte (c .Input ))
262
+ if err != nil && ! c .ExpectedError {
263
+ t .Errorf ("UnmarshalText(%q) error:\n %+v" , c .Input , err )
264
+ continue
265
+ }
266
+ if err == nil && c .ExpectedError {
267
+ t .Errorf ("UnmarshalText(%q) got %v but expected error" , c .Input , cc )
268
+ continue
269
+ }
270
+ if cc != c .Expected {
271
+ t .Errorf ("UnmarshalText(%q) got %v but expected %v" , c .Input , cc , c .Expected )
272
+ continue
273
+ }
274
+ }
275
+ }
0 commit comments