This repository has been archived by the owner on May 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathtext_test.go
96 lines (75 loc) · 2.38 KB
/
text_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
92
93
94
95
96
package goscholar
import (
"testing"
)
func TestParseYearText(t *testing.T) {
// test case 1
s := "Y LeCun, Y Bengio, G Hinton - Nature, 2015 - nature.com"
expected := "2015"
if actual := parseYearText(s); actual != expected {
t.Error(testErr{expected: expected, actual: actual})
}
// test case 1
s = "Y Bengio, AC Courville, P Vincent - CoRR, abs/1206.5538, 2012"
expected = "2012"
if actual := parseYearText(s); actual != expected {
t.Error(testErr{expected: expected, actual: actual})
}
}
func TestParseClusterIdText(t *testing.T) {
url := "/scholar?cites=5362332738201102290&as_sdt=2005&sciodt=0,5&hl=en"
expected := "5362332738201102290"
if actual := parseClusterIdText(url); actual != expected {
t.Error(testErr{expected: expected, actual: actual})
}
}
func TestParseNumCiteText(t *testing.T) {
s := "Cited by 390"
expected := "390"
if actual := parseNumCiteText(s); actual != expected {
t.Error(testErr{expected: expected, actual: actual})
}
}
func TestParseNumVerText(t *testing.T) {
s := "All 7 versions"
expected := "7"
if actual := parseNumVerText(s); actual != expected {
t.Error(testErr{expected: expected, actual: actual})
}
}
func TestParseInfoIdText(t *testing.T) {
url := "/scholar?q=related:0qfs6zbVakoJ:scholar.google.com/&hl=en&as_sdt=0,5"
expected := "0qfs6zbVakoJ"
if actual := parseInfoIdText(url); actual != expected {
t.Error(testErr{expected: expected, actual: actual})
}
}
func TestParseLinkText(t *testing.T) {
s := "psu.edu [PDF]"
expectedName := "psu.edu"
expectedFormat := "PDF"
actualName, actualFormat := parseLinkText(s)
if actualName != expectedName {
t.Error(testErr{expected: expectedName, actual: actualName})
}
if actualFormat != expectedFormat {
t.Error(testErr{expected: expectedFormat, actual: actualFormat})
}
}
func TestEnclosedInDoubleQuotation(t *testing.T) {
s1 := "y bengio"
s2 := "\"y bengio\""
if enclosedInDoubleQuotation(s1) {
t.Error("%v is not enclosed in double quotation")
}
if !enclosedInDoubleQuotation(s2) {
t.Error("%v is enclosed in double quotation")
}
}
func TestGenerateBibTeXLink(t *testing.T) {
infoId := "b2pGeL14LLMJ"
expected := "https://scholar.google.co.jp/scholar.bib?q=info:b2pGeL14LLMJ:scholar.google.com/&output=citation&hl=en&ct=citation"
if bibtexLink := generateBibTeXLink(infoId); expected != bibtexLink {
t.Error(testErr{expected: expected, actual: bibtexLink})
}
}