-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathposts_bibtext_test.go
91 lines (87 loc) · 1.68 KB
/
posts_bibtext_test.go
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package website
import (
"net/url"
"strings"
"testing"
"github.com/verifa/website/testutil"
)
func mustParseURL(t *testing.T, s string) *url.URL {
u, err := url.Parse(s)
if err != nil {
t.Fatal(err)
}
return u
}
func TestBibtex(t *testing.T) {
type test struct {
name string
input func() string
exp references
}
tests := []test{
{
name: "article",
input: func() string {
return `@article{article,
author = {Forsgren, Nicole and Kalliamvakou, Eirini and Noda, Abi and Greiler, Michaela and Houck, Brian and Storey, Margaret-Anne},
year = {2024},
month = {01},
pages = {47-77},
title = {DevEx in Action: A study of its tangible impacts},
volume = {21},
journal = {Queue},
doi = {10.1145/3639443}
url = {https://dl.acm.org/doi/10.1145/3639443}
}`
},
exp: references{
{
Key: "article",
Index: 1,
Type: "article",
Title: "DevEx in Action: A study of its tangible impacts",
Authors: []author{
{
First: "Nicole",
Last: "Forsgren",
},
{
First: "Eirini",
Last: "Kalliamvakou",
},
{
First: "Abi",
Last: "Noda",
},
{
First: "Michaela",
Last: "Greiler",
},
{
First: "Brian",
Last: "Houck",
},
{
First: "Margaret-Anne",
Last: "Storey",
},
},
Year: "2024",
URL: mustParseURL(
t,
"https://dl.acm.org/doi/10.1145/3639443",
),
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
entries, err := readBibtex(strings.NewReader(tt.input()))
if err != nil {
t.Fatal(err)
}
testutil.AssertNoDiff(t, tt.exp, entries)
})
}
}