aboutsummaryrefslogtreecommitdiffstats
path: root/skate/doi_test.go
blob: 7a184d35bf7086f12d111ea3619e7767d393eea7 (plain)
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
28
29
30
31
32
package skate

import "testing"

func TestSanitizeDOI(t *testing.T) {
	var cases = []struct {
		in  string
		out string
	}{
		{"", ""},
		{"a", ""},
		{"???", ""},
		{"10.1234", ""},
		{"10.1234/asdf ", "10.1234/asdf"},
		{"10.1234/ASDF", "10.1234/asdf"},
		{"10.1037/0002-9432.72.1.50", "10.1037/0002-9432.72.1.50"},
		{"http://doi.org/10.1234/asdf ", "10.1234/asdf"},
		{"http://doi.org/10.123", ""},
		{"dx.doi.org/10.1234/asdf ", "10.1234/asdf"},
		{"21924DOI10.1234/asdf ", "10.1234/asdf"},
		{"https://dx.doi.org/10.1234/asdf ", "10.1234/asdf"},
		{"doi:10.1234/asdf ", "10.1234/asdf"},
		{"10.7326/M20-6817", "10.7326/m20-6817"},
		// TODO: {"10.1037//0002-9432.72.1.50", "10.1037/0002-9432.72.1.50"},
	}
	for _, c := range cases {
		out := SanitizeDOI(c.in)
		if out != c.out {
			t.Fatalf("got %v, want %v", out, c.out)
		}
	}
}