35 lines
907 B
Go
35 lines
907 B
Go
package command
|
|
|
|
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",
|
|
},
|
|
}
|
|
|
|
for _, kase := range cases {
|
|
eq(t, dedent(kase.input), kase.expected)
|
|
}
|
|
}
|