forked from cli/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhelp_test.go
More file actions
46 lines (42 loc) · 1.05 KB
/
help_test.go
File metadata and controls
46 lines (42 loc) · 1.05 KB
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
package root
import (
"testing"
)
func TestDedent(t *testing.T) {
type c struct {
input string
expected string
}
cases := []c{
{
input: " --help Show help for command\n --version Show gh version\n",
expected: "--help Show help for command\n--version Show gh version\n",
},
{
input: " --help Show help for command\n -R, --repo OWNER/REPO Select another repository using the OWNER/REPO format\n",
expected: " --help Show help for command\n-R, --repo OWNER/REPO Select another repository using the OWNER/REPO format\n",
},
{
input: " line 1\n\n line 2\n line 3",
expected: " line 1\n\n line 2\nline 3",
},
{
input: " line 1\n line 2\n line 3\n\n",
expected: "line 1\nline 2\nline 3\n\n",
},
{
input: "\n\n\n\n\n\n",
expected: "\n\n\n\n\n\n",
},
{
input: "",
expected: "",
},
}
for _, tt := range cases {
got := dedent(tt.input)
if got != tt.expected {
t.Errorf("expected: %q, got: %q", tt.expected, got)
}
}
}