-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsref-db_test.go
More file actions
42 lines (34 loc) · 919 Bytes
/
sref-db_test.go
File metadata and controls
42 lines (34 loc) · 919 Bytes
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
package main
import (
"testing"
)
func TestIsEmail(t *testing.T) {
goodEmail := "foo@gmail.com"
if !IsEmail(goodEmail) {
t.Errorf("IsEmail failed to detect correct email")
}
badEmail := "badstuff.com"
if IsEmail(badEmail) {
t.Errorf("IsEmail failed to detect bad email")
}
}
func TestCaptureDoi(t *testing.T) {
s := "https://doi.org/10.1038/nature01014"
want := "10.1038/nature01014"
doi, err := CaptureDoi(s)
if err != nil {
t.Errorf("CaptureDoi return error with valid DOI")
}
if doi != want {
t.Errorf("CaptureDoi failed to capture valid DOI")
}
// ---
badDoi := "https://www.jstor.org/stable/45135882"
doi, err = CaptureDoi(badDoi)
if err == nil {
t.Errorf("CaptureDoi return ok with bad DOI")
}
if doi != "" {
t.Errorf("CaptureDoi return non empty string with bad DOI")
}
}