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 pathutils.go
84 lines (76 loc) · 2.06 KB
/
utils.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
package goscholar
import (
"fmt"
)
type testErr struct {
expected string
actual string
}
func (e testErr) Error() string {
return fmt.Sprintf("\nExpected: %v\n Actual: %v", e.expected, e.actual)
}
func same(a *Article, b *Article) (ok bool) {
titleName := a.Title.Name == b.Title.Name
titleUrl := a.Title.Url == b.Title.Url
year := a.Year == b.Year
cluster_id := a.ClusterId == b.ClusterId
numCite := a.NumCite == b.NumCite // TODO: fix; check by range
numVer := a.NumVer == b.NumVer // TODO: fix; check by range
info_id := a.InfoId == b.InfoId
linkName := a.Link.Name == b.Link.Name
linkUrl := a.Link.Url == b.Link.Url
linkFormat := a.Link.Format == b.Link.Format
return titleName && titleUrl && year && cluster_id && numCite && numVer && info_id && linkName && linkUrl && linkFormat
}
func showDifference(a *Article, b *Article) {
if a.Title.Name != b.Title.Name {
fmt.Println("Title.Name is different")
fmt.Println(a.Title.Name)
fmt.Println(b.Title.Name)
}
if a.Title.Url != b.Title.Url {
fmt.Println("Title.Url is different")
fmt.Println(a.Title.Url)
fmt.Println(b.Title.Url)
}
if a.Year != b.Year {
fmt.Println("Year is different")
fmt.Println(a.Year)
fmt.Println(b.Year)
}
if a.ClusterId != b.ClusterId {
fmt.Println("ClusterId is different")
fmt.Println(a.ClusterId)
fmt.Println(b.ClusterId)
}
if a.NumCite != b.NumCite {
fmt.Println("NumCite is different")
fmt.Println(a.NumCite)
fmt.Println(b.NumCite)
}
if a.NumVer != b.NumVer {
fmt.Println("NumVer is different")
fmt.Println(a.NumVer)
fmt.Println(b.NumVer)
}
if a.InfoId != b.InfoId {
fmt.Println("InfoId is different")
fmt.Println(a.InfoId)
fmt.Println(b.InfoId)
}
if a.Link.Name != b.Link.Name {
fmt.Println("Link.Name is different")
fmt.Println(a.Link.Name)
fmt.Println(b.Link.Name)
}
if a.Link.Url != b.Link.Url {
fmt.Println("Link.Url is different")
fmt.Println(a.Link.Url)
fmt.Println(b.Link.Url)
}
if a.Link.Format != b.Link.Format {
fmt.Println("Title.Format is different")
fmt.Println(a.Link.Format)
fmt.Println(b.Link.Format)
}
}