-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_test.go
48 lines (45 loc) · 1.03 KB
/
main_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
package main
import "testing"
func TestClearString(t *testing.T) {
tests := []struct {
name string
input string
output string
}{
{"TestClearString - 1", "hello", "hello"},
{"TestClearString - 2", " hello", "hello"},
{"TestClearString - 3", "hello ", "hello"},
{"TestClearString - 4", " hello ", "hello"},
{"TestClearString - 5", "", ""},
{"TestClearString - 6", " ", ""},
{"TestClearString - 7", " ", ""},
{"TestClearString - 8", " ", ""},
{"TestClearString - 9", " he llo ", "he llo"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if clearString(tt.input) != tt.output {
t.Fail()
}
})
}
}
func TestIsEmpty(t *testing.T) {
tests := []struct {
name string
input string
output bool
}{
{"TestIsEmpty - 1", " ", true},
{"TestIsEmpty - 2", "hello", false},
{"TestIsEmpty - 3", "hel lo ", false},
{"TestIsEmpty - 4", " f ", false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if isEmpty(tt.input) != tt.output {
t.Fail()
}
})
}
}