OSDN Git Service

libgo: Update to weekly.2011-11-18.
[pf3gnuchains/gcc-fork.git] / libgo / go / mime / type_test.go
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.
4
5 package mime
6
7 import "testing"
8
9 var typeTests = initMimeForTests()
10
11 func TestTypeByExtension(t *testing.T) {
12         for ext, want := range typeTests {
13                 val := TypeByExtension(ext)
14                 if val != want {
15                         t.Errorf("TypeByExtension(%q) = %q, want %q", ext, val, want)
16                 }
17
18         }
19 }
20
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)
25         }
26         if registered := TypeByExtension(".xml"); registered != custom {
27                 t.Fatalf("registered %s instead of %s", registered, custom)
28         }
29 }