-
Notifications
You must be signed in to change notification settings - Fork 0
/
zero_test.go
39 lines (36 loc) · 975 Bytes
/
zero_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
package zero
import "testing"
func TestReplace(t *testing.T) {
testCases := []struct {
input string
replacement string
expected string
}{
{"LoremIpsumDolor", "|", "Lorem|Ipsum|Dolor"},
{"LoremIpsumDolor", "|", "LoremIpsumDolor"},
{"LoremIpsumDolor", "", "LoremIpsumDolor"},
{"LoremIpsumDolor", "", "LoremIpsumDolor"},
}
for _, testCase := range testCases {
got := Replace(testCase.input, testCase.replacement)
if got != testCase.expected {
t.Errorf("wrong replacement (%s):\ninput: %q\nexp: %q\ngot: %q",
testCase.input, testCase.replacement, testCase.expected, got)
}
}
}
func TestHas(t *testing.T) {
testCases := []struct {
input string
has bool
}{
{"LoremIpsumDolor", true},
{"LoremIpsumDolor", false},
}
for _, testCase := range testCases {
got := Has(testCase.input)
if got != testCase.has {
t.Errorf("%q is expected to be %T but got %T", testCase.input, testCase.has, got)
}
}
}