zeroshade commented on code in PR #357: URL: https://github.com/apache/arrow-go/pull/357#discussion_r2049733390
########## parquet/compress/compress_test.go: ########## @@ -138,3 +138,23 @@ func TestCompressReaderWriter(t *testing.T) { }) } } + +func TestMarshalText(t *testing.T) { + compression := compress.Codecs.Zstd + data, err := compression.MarshalText() + assert.NoError(t, err) + assert.Equal(t, "ZSTD", string(data)) +} + +func TestUnmarshalText(t *testing.T) { + var compression compress.Compression + err := compression.UnmarshalText([]byte("ZSTD")) + assert.NoError(t, err) + assert.Equal(t, compress.Codecs.Zstd, compression) +} Review Comment: I figured we should probably use a table test and test all the codes. i.e. ```go func TestMarshalText(t *testing.T) { tests := []struct{ codec .... text string }{ {compress.Codecs.Zstd, "ZSTD"}, {compress.Codecs.Snappy, "SNAPPY"}, ... } for _, tt := range tests { t.Run(tt.text, func(t *testing.T) { data, err := tt.codec.MarshalText() assert.NoError(t, err) assert.Equal(t, tt.text, string(data)) ... }) } } ``` and so on ########## parquet/compress/compress_test.go: ########## @@ -138,3 +138,23 @@ func TestCompressReaderWriter(t *testing.T) { }) } } + +func TestMarshalText(t *testing.T) { + compression := compress.Codecs.Zstd + data, err := compression.MarshalText() + assert.NoError(t, err) + assert.Equal(t, "ZSTD", string(data)) +} + +func TestUnmarshalText(t *testing.T) { + var compression compress.Compression + err := compression.UnmarshalText([]byte("ZSTD")) + assert.NoError(t, err) + assert.Equal(t, compress.Codecs.Zstd, compression) +} Review Comment: I figured we should probably use a table test and test all the codecs. i.e. ```go func TestMarshalText(t *testing.T) { tests := []struct{ codec .... text string }{ {compress.Codecs.Zstd, "ZSTD"}, {compress.Codecs.Snappy, "SNAPPY"}, ... } for _, tt := range tests { t.Run(tt.text, func(t *testing.T) { data, err := tt.codec.MarshalText() assert.NoError(t, err) assert.Equal(t, tt.text, string(data)) ... }) } } ``` and so on -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org