aboutsummaryrefslogtreecommitdiffstats
path: root/skate/doi_test.go
diff options
context:
space:
mode:
authorMartin Czygan <martin@archive.org>2021-07-26 17:43:04 +0000
committerMartin Czygan <martin@archive.org>2021-07-26 17:43:04 +0000
commitaeaa60211e33cb49da98770b3461cbca2c2a65cc (patch)
tree1def8dfcd4d2c035a8b5ee6d88507a1ad53a8b40 /skate/doi_test.go
parentbefd7895262e2469367e2a4f71f78148b9986dee (diff)
parent0d4c3ca311b1057bdb07144b0ac8ba860be2de55 (diff)
downloadrefcat-aeaa60211e33cb49da98770b3461cbca2c2a65cc.tar.gz
refcat-aeaa60211e33cb49da98770b3461cbca2c2a65cc.zip
Merge branch 'bnewbold-skate-tweaks' into 'master'
proposed changes and fixes to skate matching See merge request martin/cgraph!3
Diffstat (limited to 'skate/doi_test.go')
-rw-r--r--skate/doi_test.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/skate/doi_test.go b/skate/doi_test.go
new file mode 100644
index 0000000..7a184d3
--- /dev/null
+++ b/skate/doi_test.go
@@ -0,0 +1,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)
+ }
+ }
+}