-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlines_test.go
More file actions
30 lines (28 loc) · 945 Bytes
/
lines_test.go
File metadata and controls
30 lines (28 loc) · 945 Bytes
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
package strings
import "testing"
func TestTrimShiftLines(t *testing.T) {
tests := []struct {
name string
s string
want string
}{
{"empty", "", ""},
{"whitespace", " ", ""},
{"empty lines", "\n\n \n ", "\n\n\n"},
{"one line no trim", "abc\n", "abc\n"},
{"one line with trim", " abc\n", "abc\n"},
{"one line with end trim", " abc \n", "abc\n"},
{"two lines", " abc \n def", " abc\ndef"},
{"three lines", " abc \n def\n ghi", " abc\ndef\n ghi"},
{"three lines no match", "\t abc \n def\n ghi", "\t abc\n def\n ghi"},
{"three lines no match 2", " abc \n\t def\n ghi", " abc\n\t def\n ghi"},
{"three lines no match 3", " abc \n\t def\n ghi", " abc\n\t def\n ghi"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := TrimShiftLines(tt.s); got != tt.want {
t.Errorf("TrimShiftLines() = %v, want %v", got, tt.want)
}
})
}
}