-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
clearpath_test.go
77 lines (72 loc) · 2.61 KB
/
clearpath_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
package hit_test
import (
"bytes"
"crypto/rand"
"io"
"testing"
. "github.com/Eun/go-hit"
)
func TestClearPath_Contains(t *testing.T) {
tests := []struct {
haystack CallPath
needle CallPath
want bool
}{
{NewCallPath("Foo", nil).Push("Bar", nil), NewCallPath("Foo", nil).Push("Bar", nil), true},
{NewCallPath("Foo", nil).Push("Bar", nil), NewCallPath("Foo", nil), true},
{NewCallPath("Foo", nil).Push("Bar", nil), NewCallPath("Foo", []interface{}{1}), false},
{NewCallPath("Foo", []interface{}{1}).Push("Bar", nil), NewCallPath("Foo", nil), true},
{NewCallPath("Foo", []interface{}{1}).Push("Bar", nil), NewCallPath("Foo", nil).Push("Bar", nil), true},
{NewCallPath("Foo", []interface{}{1}).Push("Bar", nil), NewCallPath("Foo", []interface{}{1}), true},
{NewCallPath("Foo", []interface{}{1}).Push("Bar", nil), NewCallPath("Foo", []interface{}{1}).Push("Bar", nil), true},
{NewCallPath("Foo", []interface{}{1}).Push("Bar", []interface{}{1}), NewCallPath("Foo", []interface{}{1}).Push("Bar", []interface{}{1}), true},
{NewCallPath("Foo", []interface{}{1}).Push("Bar", nil), NewCallPath("Foo", []interface{}{2}), false},
{NewCallPath("Foo", []interface{}{1, 2}).Push("Bar", nil), NewCallPath("Foo", []interface{}{1}), true},
{NewCallPath("Foo", []interface{}{1}).Push("Bar", nil), NewCallPath("Foo", []interface{}{1, 2}), false},
}
for _, tt := range tests {
t.Run("", func(t *testing.T) {
if got := tt.haystack.Contains(tt.needle); got != tt.want {
t.Errorf("Contains() = %v, want %v", got, tt.want)
}
})
}
}
func TestClearPath_ContainsFunc(t *testing.T) {
f1 := func(Hit) {}
f2 := func(Hit) {}
tests := []struct {
haystack CallPath
needle CallPath
want bool
}{
{NewCallPath("Foo", []interface{}{f1}), NewCallPath("Foo", []interface{}{f1}), true},
{NewCallPath("Foo", []interface{}{f2}), NewCallPath("Foo", []interface{}{f1}), false},
}
for _, tt := range tests {
t.Run("", func(t *testing.T) {
if got := tt.haystack.Contains(tt.needle); got != tt.want {
t.Errorf("Contains() = %v, want %v", got, tt.want)
}
})
}
}
func TestClearPath_ContainsReader(t *testing.T) {
var r1 io.Reader = bytes.NewReader(nil)
r2 := rand.Reader
tests := []struct {
haystack CallPath
needle CallPath
want bool
}{
{NewCallPath("Foo", []interface{}{r1}), NewCallPath("Foo", []interface{}{r1}), true},
{NewCallPath("Foo", []interface{}{r2}), NewCallPath("Foo", []interface{}{r1}), false},
}
for _, tt := range tests {
t.Run("", func(t *testing.T) {
if got := tt.haystack.Contains(tt.needle); got != tt.want {
t.Errorf("Contains() = %v, want %v", got, tt.want)
}
})
}
}