-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathflag_test.go
More file actions
37 lines (27 loc) · 747 Bytes
/
flag_test.go
File metadata and controls
37 lines (27 loc) · 747 Bytes
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
package configure
import (
"testing"
)
func TestFlagStrings(t *testing.T) {
f, ff := createFlag(t, "--x=hello", `--z=hello world`, "--y=22")
test(value(f.String("x")), "hello", ff)
test(value(f.String("z")), "hello world", ff)
test(value(f.String("y")), "22", ff)
}
func TestFlagsInts(t *testing.T) {
f, ff := createFlag(t, "--x=2", "--z=-1")
test(value(f.Int("x")), 2, ff)
test(value(f.Int("z")), -1, ff)
}
func TestFlagsBools(t *testing.T) {
f, ff := createFlag(t, "--x=T", "--z=F")
test(value(f.Bool("x")), true, ff)
test(value(f.Bool("z")), false, ff)
}
func createFlag(t *testing.T, args ...string) (Flag, func()) {
f := Flag{
args: append([]string{"executable"}, args...),
}
ff := normalFailFunc(t)
return f, ff
}