You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
588 B
41 lines
588 B
package mime_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
"gitoa.ru/go-4devs/mime"
|
|
)
|
|
|
|
func TestExtUnmarshalText(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
cases := []struct {
|
|
data string
|
|
expext mime.Ext
|
|
}{
|
|
{
|
|
data: "txt",
|
|
expext: mime.ExtTxt,
|
|
},
|
|
{
|
|
data: "TXT",
|
|
expext: mime.ExtUnrecognized,
|
|
},
|
|
{
|
|
data: "C",
|
|
expext: mime.Ext_C,
|
|
},
|
|
{
|
|
data: "c",
|
|
expext: mime.ExtC,
|
|
},
|
|
}
|
|
|
|
for _, cs := range cases {
|
|
var in mime.Ext
|
|
err := in.UnmarshalText([]byte(cs.data))
|
|
require.Equal(t, cs.expext, in)
|
|
require.NoError(t, err)
|
|
}
|
|
}
|
|
|