forked from abadojack/swot
-
Notifications
You must be signed in to change notification settings - Fork 2
/
swot_test.go
95 lines (90 loc) · 2.38 KB
/
swot_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
package swot
import (
"testing"
)
func TestIsAcademic(t *testing.T) {
var tests = []struct {
address string
result bool
}{
{"[email protected]", true},
{"[email protected]", true},
{"[email protected]", true},
{"[email protected]", true},
{"[email protected]", true},
{"[email protected]", true},
{"[email protected]", true},
{"[email protected]", true},
{"[email protected]", true},
{"[email protected]", true},
{"stanford.edu", true},
{"slac.stanford.edu", true},
{"www.stanford.edu", true},
{"http://www.stanford.edu", true},
{"http://www.stanford.edu:9393", true},
{"strath.ac.uk", true},
{"soft-eng.strath.ac.uk", true},
{"ugr.es", true},
{"uottawa.ca", true},
{"mother.edu.ru", true},
{"ucy.ac.cy", true},
{" stanford.edu", true},
{"[email protected] ", true},
{"[email protected]", true},
{"[email protected]", true},
{"[email protected]", true},
{"[email protected]", true},
{"[email protected]", true},
{"[email protected]", false},
{"[email protected]", false},
{"[email protected]", false},
{"[email protected]", false},
{"leerilly.net", false},
{"gmail.com", false},
{"stanford.edu.com", false},
{"strath.ac.uk.com", false},
{"", false},
{"the", false},
{" gmail.com ", false},
{"si.edu", false},
{" si.edu ", false},
{"[email protected]", false},
{"foo.si.edu", false},
{"america.edu", false},
{"folger.edu", false},
{"[email protected]", true},
{"[email protected]", true},
{"[email protected]", true},
{"[email protected]", true},
{"[email protected]", true},
}
for _, tt := range tests {
address := tt.address
result := IsAcademic(address)
if result != tt.result {
t.Errorf("%s got %t, want %t", address, result, tt.result)
}
}
}
func TestGetSchoolName(t *testing.T) {
var tests = []struct {
address string
result string
}{
{"[email protected]", "University of Strathclyde"},
{"[email protected]", "BRG Fadingerstraße Linz, Austria"},
{"[email protected]", ""},
{"[email protected]", ""},
{"gmail.com", ""},
{"harvard.edu", "Harvard University"},
{"stanford.edu", "Stanford University"},
{"http://www.stanford.edu:9393", "Stanford University"},
}
for _, tt := range tests {
address := tt.address
result := GetSchoolName(address)
if result != tt.result {
t.Errorf("%s got %s, want %s", address, result, tt.result)
}
}
}