-
Notifications
You must be signed in to change notification settings - Fork 17
/
utilities_test.go
60 lines (54 loc) · 1.11 KB
/
utilities_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
package main
func testStringEq(a, b []string) bool {
// If one is nil, the other must also be nil.
if (a == nil) != (b == nil) {
return false
}
if len(a) != len(b) {
return false
}
for i := range a {
if a[i] != b[i] {
return false
}
}
return true
}
type funcCounter struct {
count []funcCounterImpl
}
type funcCounterImpl struct {
name string
params []interface{}
}
func (f *funcCounter) add(name string, params ...interface{}) {
f.count = append(f.count, funcCounterImpl{
name: name,
params: params,
})
}
func (f *funcCounter) last() (string, []interface{}) { //nolint:unused
l := len(f.count)
if l > 0 {
return f.count[l-1].name, f.count[l-1].params
}
return "", nil
}
func (f *funcCounter) lastByName(name string) []interface{} { //nolint:unused
var params []interface{}
for _, call := range f.count {
if call.name == name {
params = call.params
}
}
return params
}
func (f *funcCounter) filterByName(name string) []funcCounterImpl {
ret := make([]funcCounterImpl, 0)
for _, call := range f.count {
if call.name == name {
ret = append(ret, call)
}
}
return ret
}