-
Notifications
You must be signed in to change notification settings - Fork 0
/
search_test.go
140 lines (111 loc) · 4.62 KB
/
search_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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
package assertion
import (
"testing"
)
func TestAssertion_StartsWith_ReturnsTrue(t *testing.T) {
data := []MethodDataOK{
{"StartsWith", []interface{}{"Hello world!", "Hello"}},
}
assertAllReturnsTrue(t, data)
}
func TestAssertion_StartsWith_ReturnsFalse(t *testing.T) {
data := []MethodDataKO{
{"StartsWith", []interface{}{"Hello world!", "hello"}, "Hello world! does not start with hello"},
{"StartsWith", []interface{}{"Hello world!", "ello"}, "Hello world! does not start with ello"},
{"StartsWith", []interface{}{"Hello world!", "world!"}, "Hello world! does not start with world!"},
}
assertAllReturnsFalse(t, data)
}
func TestAssertion_EndsWith_ReturnsTrue(t *testing.T) {
data := []MethodDataOK{
{"EndsWith", []interface{}{"Hello world!", "world!"}},
}
assertAllReturnsTrue(t, data)
}
func TestAssertion_EndsWith_ReturnsFalse(t *testing.T) {
data := []MethodDataKO{
{"EndsWith", []interface{}{"Hello world!", "World!"}, "Hello world! does not end with World!"},
{"EndsWith", []interface{}{"Hello world!", "world"}, "Hello world! does not end with world"},
{"EndsWith", []interface{}{"Hello world!", "Hello"}, "Hello world! does not end with Hello"},
}
assertAllReturnsFalse(t, data)
}
func TestAssertion_Contains_ReturnsTrue(t *testing.T) {
data := []MethodDataOK{
{"Contains", []interface{}{"Hello world!", "world"}},
{"Contains", []interface{}{"Hello world!", "Hello"}},
{"Contains", []interface{}{"Hello world!", "world!"}},
}
assertAllReturnsTrue(t, data)
}
func TestAssertion_Contains_ReturnsFalse(t *testing.T) {
data := []MethodDataKO{
{"Contains", []interface{}{"Hello world!", "World"}, "Hello world! does not contain World"},
{"Contains", []interface{}{"Hello world!", "lloworld"}, "Hello world! does not contain lloworld"},
{"Contains", []interface{}{"Hello world!", "hello"}, "Hello world! does not contain hello"},
}
assertAllReturnsFalse(t, data)
}
func TestAssertion_StartsWithInsensitive_ReturnsTrue(t *testing.T) {
data := []MethodDataOK{
{"StartsWithInsensitive", []interface{}{"Hello world!", "Hello"}},
{"StartsWithInsensitive", []interface{}{"Hello world!", "hello"}},
{"StartsWithInsensitive", []interface{}{"esdrújula", "ESDRÚ"}},
{"StartsWithInsensitive", []interface{}{"ESDRÚJULA", "esdrú"}},
{"StartsWithInsensitive", []interface{}{"#especial", "#esp"}},
{"StartsWithInsensitive", []interface{}{"Straße", "straß"}},
}
assertAllReturnsTrue(t, data)
}
func TestAssertion_StartsWithInsensitive_ReturnsFalse(t *testing.T) {
data := []MethodDataKO{
{"StartsWithInsensitive", []interface{}{"Hello world!", "ello"}, "Hello world! does not start with ello"},
}
assertAllReturnsFalse(t, data)
}
func TestAssertion_EndsWithInsensitive_ReturnsTrue(t *testing.T) {
data := []MethodDataOK{
{"EndsWithInsensitive", []interface{}{"Hello world!", "world!"}},
{"EndsWithInsensitive", []interface{}{"Hello WORLD!", "world!"}},
{"EndsWithInsensitive", []interface{}{"Hello world!", "WORLD!"}},
}
assertAllReturnsTrue(t, data)
}
func TestAssertion_EndsWithInsensitive_ReturnsFalse(t *testing.T) {
data := []MethodDataKO{
{"EndsWithInsensitive", []interface{}{"Hello world!", "world"}, "Hello world! does not end with world"},
{"EndsWithInsensitive", []interface{}{"Hello world!", "Hello"}, "Hello world! does not end with Hello"},
}
assertAllReturnsFalse(t, data)
}
func TestAssertion_ContainsInsensitive_ReturnsTrue(t *testing.T) {
data := []MethodDataOK{
{"ContainsInsensitive", []interface{}{"Hello world!", "WORLD"}},
{"ContainsInsensitive", []interface{}{"Hello WORLD!", "WORLD"}},
{"ContainsInsensitive", []interface{}{"Hello world!", "HELLO"}},
{"ContainsInsensitive", []interface{}{"HELLO world!", "hello"}},
{"ContainsInsensitive", []interface{}{"Hello world!", "World"}},
}
assertAllReturnsTrue(t, data)
}
func TestAssertion_ContainsInsensitive_ReturnsFalse(t *testing.T) {
data := []MethodDataKO{
{"ContainsInsensitive", []interface{}{"Hello world!", "lloworld"}, "Hello world! does not contain lloworld"},
}
assertAllReturnsFalse(t, data)
}
func TestAssertion_HasKey_ReturnsTrue(t *testing.T) {
data := []MethodDataOK{
{"HasKey", []interface{}{map[string]string{"a": "a"}, "a"}},
{"HasKey", []interface{}{map[int]string{1: "a"}, 1}},
}
assertAllReturnsTrue(t, data)
}
func TestAssertion_HasKey_ReturnsFalse(t *testing.T) {
data := []MethodDataKO{
{"HasKey", []interface{}{"Hello world!", "lloworld"}, "Hello world! has not the key lloworld"},
{"HasKey", []interface{}{map[string]string{"a": "a"}, "b"}, "map[a:a] has not the key b"},
{"HasKey", []interface{}{map[int]string{1: "a"}, 2}, "map[1:a] has not the key 2"},
}
assertAllReturnsFalse(t, data)
}