-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpositional_test.go
74 lines (57 loc) · 2.41 KB
/
positional_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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package argumentative
import "testing"
func TestNewPositional(t *testing.T) {
flag := NewPositional("longname", true, "default", "description")
if flag.Longflag != "longname" {
t.Errorf("Longflag assignment wrong, got [%s], want [%s]", flag.Longflag, "longname")
}
if flag.Default != "default" {
t.Errorf("Default assignment wrong, got [%s], want [%s]", flag.Default, "default")
}
if flag.Description != "description" {
t.Errorf("Description assignment wrong, got [%s], want [%s]", flag.Description, "description")
}
if *flag.Value != "default" {
t.Errorf("Assignment of default to value wrong, got [%s], want [%s]", *flag.Value, flag.Default)
}
}
func TestGetLongPositionalDescription(t *testing.T) {
flag := NewPositional("longname", true, "default", "description")
result := flag.GetLongDescription()
await := "longname description (Default: default)"
if result != await {
t.Errorf("Generation of long description failed, got [%s], want [%s]", result, await)
}
flag = NewPositional("longname", false, "default", "description")
result = flag.GetLongDescription()
await = "longname description (Default: default)"
if result != await {
t.Errorf("Generation of long description not required failed, got [%s], want [%s]", result, await)
}
flag = NewPositional("longname", false, "", "description")
result = flag.GetLongDescription()
await = "longname description"
if result != await {
t.Errorf("Generation of long description no default failed, got [%s], want [%s]", result, await)
}
}
func TestGetShortPositionalDescription(t *testing.T) {
flag := NewPositional("longname", true, "default", "description")
result := flag.GetShortDescription()
await := " longname" // @todo: remove space
if result != await {
t.Errorf("Generation of short description failed, got [%s], want [%s]", result, await)
}
flag = NewPositional("longname", false, "", "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)
}
flag = NewPositional("longname", false, "default", "description")
result = flag.GetShortDescription()
await = " [longname]" // @todo remove space
if result != await {
t.Errorf("Generation of short description no required but default failed, got [%s], want [%s]", result, await)
}
}