-
Notifications
You must be signed in to change notification settings - Fork 1
/
options_test.go
36 lines (31 loc) · 1.12 KB
/
options_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
package commander
import (
"github.com/WindomZ/testify/assert"
"testing"
)
func TestOptions_UsagesString(t *testing.T) {
var o _Options
o = _Options{}
assert.Equal(t, o.UsagesString(), []string(nil))
o = _Options{
newOption("-a, --about", "about description"),
newOption("-b=<kn>, --bold=<kn>", "bold description"),
newOption("-c, --config", "config description"),
newOption("-d, --drop", "drop description"),
}
assert.Equal(t, o.UsagesString(),
[]string{"[-a|--about] [-b=<kn>|--bold=<kn>] [-c|--config] [-d|--drop]"})
}
func TestOptions_OptionsString(t *testing.T) {
o := _Options{
newOption("-a, --about", "about description"),
newOption("-b=<kn>, --bold=<kn>", "bold description"),
newOption("-c, --config", "config description"),
newOption("-d, --drop", "drop description"),
}
opts := o.OptionsString()
assert.Equal(t, opts["-a|--about"], "-a --about about description")
assert.Equal(t, opts["-b|--bold"], "-b=<kn> --bold=<kn>\n bold description")
assert.Equal(t, opts["-c|--config"], "-c --config config description")
assert.Equal(t, opts["-d|--drop"], "-d --drop drop description")
}