diff options
Diffstat (limited to 'libgo/go/mime/mediatype_test.go')
-rw-r--r-- | libgo/go/mime/mediatype_test.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/libgo/go/mime/mediatype_test.go b/libgo/go/mime/mediatype_test.go index c06f167..64ab291 100644 --- a/libgo/go/mime/mediatype_test.go +++ b/libgo/go/mime/mediatype_test.go @@ -253,3 +253,24 @@ func TestParseMediaTypeBogus(t *testing.T) { t.Errorf("expected invalid media parameter; got error %q", err) } } + +type formatTest struct { + typ string + params map[string]string + want string +} + +var formatTests = []formatTest{ + {"noslash", nil, ""}, + {"foo/BAR", nil, "foo/bar"}, + {"foo/BAR", map[string]string{"X": "Y"}, "foo/bar; x=Y"}, +} + +func TestFormatMediaType(t *testing.T) { + for i, tt := range formatTests { + got := FormatMediaType(tt.typ, tt.params) + if got != tt.want { + t.Errorf("%d. FormatMediaType(%q, %v) = %q; want %q", i, tt.typ, tt.params, got, tt.want) + } + } +} |