forked from abadojack/swot
-
Notifications
You must be signed in to change notification settings - Fork 1
/
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
}{
{"lreilly@stanford.edu", true},
{"LREILLY@STANFORD.EDU", true},
{"Lreilly@Stanford.Edu", true},
{"lreilly@slac.stanford.edu", true},
{"lreilly@strath.ac.uk", true},
{"lreilly@soft-eng.strath.ac.uk", true},
{"lee@ugr.es", true},
{"lee@uottawa.ca", true},
{"lee@mother.edu.ru", true},
{"lee@ucy.ac.cy", 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},
{"lee@strath.ac.uk ", true},
{"lee@niagaracollege.ca", true},
{"lee@ncstudents.niagaracollege.ca", true},
{"lee@stud.uni-corvinus.hu", true},
{"lee@harvard.edu", true},
{"lee@mail.harvard.edu", true},
{"lee@leerilly.net", false},
{"lee@gmail.com", false},
{"lee@stanford.edu.com", false},
{"lee@strath.ac.uk.com", 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},
{"imposter@si.edu", false},
{"foo.si.edu", false},
{"america.edu", false},
{"folger.edu", false},
{"foo@stud.fit.ac.cy", true},
{"foo@stud.frederick.ac.cy", true},
{"foo@fit.ac.cy", true},
{"foo@frederick.ac.cy", true},
{"foo@uds.berlin", 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
}{
{"lreilly@cs.strath.ac.uk", "University of Strathclyde"},
{"lreilly@fadi.at", "BRG Fadingerstraße Linz, Austria"},
{"foo@shop.com", ""},
{"bar@gmail.com", ""},
{"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)
}
}
}