aboutsummaryrefslogtreecommitdiffstats
path: root/skate/unstructured_test.go
diff options
context:
space:
mode:
authorMartin Czygan <martin.czygan@gmail.com>2021-05-05 00:20:03 +0200
committerMartin Czygan <martin.czygan@gmail.com>2021-05-05 00:20:03 +0200
commit13f89091ed93c5166e0fd969665e3e9f2c909ca9 (patch)
treed7b34063782e4985238cd4f36f1b6d6ae11375c1 /skate/unstructured_test.go
parent2f584059a7ec85ac1977e90f5ffeae251f956eeb (diff)
downloadrefcat-13f89091ed93c5166e0fd969665e3e9f2c909ca9.tar.gz
refcat-13f89091ed93c5166e0fd969665e3e9f2c909ca9.zip
add test for ParseUnstructured
Diffstat (limited to 'skate/unstructured_test.go')
-rw-r--r--skate/unstructured_test.go53
1 files changed, 53 insertions, 0 deletions
diff --git a/skate/unstructured_test.go b/skate/unstructured_test.go
new file mode 100644
index 0000000..e6e9fbd
--- /dev/null
+++ b/skate/unstructured_test.go
@@ -0,0 +1,53 @@
+package skate
+
+import (
+ "reflect"
+ "testing"
+)
+
+func TestParseUnstructured(t *testing.T) {
+ var cases = []struct {
+ ref *Ref
+ result *Ref
+ err error
+ }{
+ {
+ &Ref{
+ Biblio: Biblio{
+ Unstructured: "Hello 10.1111/j.1550-7408.1968.tb02138.x-BIB5",
+ },
+ },
+ &Ref{
+ Biblio: Biblio{
+ DOI: "10.1111/j.1550-7408.1968.tb02138.x-BIB5",
+ Unstructured: "Hello 10.1111/j.1550-7408.1968.tb02138.x-BIB5",
+ },
+ },
+ nil,
+ },
+ {
+ &Ref{
+ Biblio: Biblio{
+ Unstructured: "https://arxiv.org/pdf/0808.3320v3.pdf Hello 10.1111/j.1550-7408.1968.tb02138.x-BIB5",
+ },
+ },
+ &Ref{
+ Biblio: Biblio{
+ ArxivId: "0808.3320",
+ DOI: "10.1111/j.1550-7408.1968.tb02138.x-BIB5",
+ Unstructured: "https://arxiv.org/pdf/0808.3320v3.pdf Hello 10.1111/j.1550-7408.1968.tb02138.x-BIB5",
+ },
+ },
+ nil,
+ },
+ }
+ for _, c := range cases {
+ err := ParseUnstructured(c.ref)
+ if err != c.err {
+ t.Fatalf("got %v, want %v", err, c.err)
+ }
+ if !reflect.DeepEqual(c.ref, c.result) {
+ t.Fatalf("got %#v, want %#v", c.ref, c.result)
+ }
+ }
+}