aboutsummaryrefslogtreecommitdiffstats
path: root/skate/unstructured_test.go
blob: 41ff471d9af6261a4d84926b538f48abd4ab7d9a (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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package skate

import (
	"reflect"
	"testing"
)

func TestParseUnstructured(t *testing.T) {
	// XXX: add more cases, maybe move this into files.
	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)
		}
	}
}