File: split_test.go

package info (click to toggle)
golang-gopkg-h2non-filetype.v1 1.1.3%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 208 kB
  • sloc: makefile: 4
file content (27 lines) | stat: -rw-r--r-- 505 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package types

import "testing"

func TestSplit(t *testing.T) {
	cases := []struct {
		mime    string
		kind    string
		subtype string
	}{
		{"image/jpeg", "image", "jpeg"},
		{"/jpeg", "", "jpeg"},
		{"image/", "image", ""},
		{"/", "", ""},
		{"image", "image", ""},
	}

	for _, test := range cases {
		kind, subtype := splitMime(test.mime)
		if test.kind != kind {
			t.Fatalf("Invalid kind: %s", test.kind)
		}
		if test.subtype != subtype {
			t.Fatalf("Invalid subtype: %s", test.subtype)
		}
	}
}