1 // Copyright 2010 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
9 var typeTests
= initMimeForTests()
11 func TestTypeByExtension(t
*testing
.T
) {
12 for ext
, want
:= range typeTests
{
13 val
:= TypeByExtension(ext
)
15 t
.Errorf("TypeByExtension(%q) = %q, want %q", ext
, val
, want
)
21 func TestCustomExtension(t
*testing
.T
) {
22 custom
:= "text/xml; charset=iso-8859-1"
23 if error
:= AddExtensionType(".xml", custom
); error
!= nil {
24 t
.Fatalf("error %s for AddExtension(%s)", error
, custom
)
26 if registered
:= TypeByExtension(".xml"); registered
!= custom
{
27 t
.Fatalf("registered %s instead of %s", registered
, custom
)