-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathboolflag_test.go
59 lines (45 loc) · 1.73 KB
/
boolflag_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
49
50
51
52
53
54
55
56
57
58
59
package argumentative
import "testing"
func TestNewBoolFlag(t *testing.T) {
flag := NewBoolFlag("longname", "s", "description")
if flag.Longflag != "longname" {
t.Errorf("Longflag assignment wrong, got [%s], want [%s]", flag.Longflag, "longname")
}
if flag.Shortflag != "s" {
t.Errorf("Shortflag assignment wrong, got [%s], want [%s]", flag.Shortflag, "s")
}
if flag.Description != "description" {
t.Errorf("Description assignment wrong, got [%s], want [%s]", flag.Description, "description")
}
if *flag.Value != false {
t.Errorf("Assignment of default to value wrong, got [%t], want [%t]", *flag.Value, false)
}
}
func TestGetLongBoolDescription(t *testing.T) {
flag := NewBoolFlag("longname", "s", "description")
result := flag.GetLongDescription()
await := "-s, --longname description"
if result != await {
t.Errorf("Generation of long description failed, got [%s], want [%s]", result, await)
}
flag = NewBoolFlag("longname", "", "description")
result = flag.GetLongDescription()
await = "--longname description"
if result != await {
t.Errorf("Generation of long description without default failed, got [%s], want [%s]", result, await)
}
}
func TestGetShortBoolDescription(t *testing.T) {
flag := NewBoolFlag("longname", "s", "description")
result := flag.GetShortDescription()
await := " [-s]" // @todo: remove space
if result != await {
t.Errorf("Generation of short description failed, got [%s], want [%s]", result, await)
}
flag = NewBoolFlag("longname", "", "description")
result = flag.GetShortDescription()
await = " [--longname]" // @todo remove space
if result != await {
t.Errorf("Generation of short description no required failed, got [%s], want [%s]", result, await)
}
}