-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathutils_test.go
More file actions
41 lines (39 loc) · 1.16 KB
/
utils_test.go
File metadata and controls
41 lines (39 loc) · 1.16 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
package argparse
import (
"strings"
"testing"
)
func TestFormatHelpRow(t *testing.T) {
width := decideTerminalWidth()
header := "this is header"
if strings.Count(formatHelpRow(header, strings.Repeat("C", 50), len(header), 30, width, false),
"\n") > 0 {
t.Error("should be only one line")
return
}
if strings.Count(formatHelpRow(header, strings.Repeat("C", 51), len(header), 30, width, false),
"\n") != 1 {
t.Error("should be exactly one line")
return
}
header = "short_e"
if strings.Count(formatHelpRow(header, strings.Repeat("C", 51), len(header), 10, width, true), "\n") > 0 {
t.Error("should be exactly one line")
return
}
header = "short_f"
if strings.Count(formatHelpRow(header, strings.Repeat("C", 91), len(header), 10, width, true), "\n") != 1 {
t.Error("should be exactly two line")
return
}
header = "the_long"
if strings.Count(formatHelpRow(header, strings.Repeat("C", 51), len(header), 10, width, true), "\n") != 1 {
t.Error("two line")
return
}
header = "this is very long too"
if strings.Count(formatHelpRow(header, strings.Repeat("C", 91), len(header), 10, width, true), "\n") != 2 {
t.Error("line break error")
return
}
}