MCPcopy
hub / github.com/mislav/hub / TestArgsParser_Bool

Function TestArgsParser_Bool

utils/args_parser_test.go:91–107  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

89}
90
91func TestArgsParser_Bool(t *testing.T) {
92 p := NewArgsParser()
93 p.RegisterBool("--noop")
94 p.RegisterBool("--color")
95 p.RegisterBool("--draft", "-d")
96 args := []string{"-d", "--draft=false", "--color=auto"}
97 rest, err := p.Parse(args)
98 equal(t, nil, err)
99 equal(t, []string{}, rest)
100 equal(t, false, p.Bool("--draft"))
101 equal(t, true, p.HasReceived("--draft"))
102 equal(t, false, p.HasReceived("-d"))
103 equal(t, false, p.HasReceived("--noop"))
104 equal(t, false, p.Bool("--noop"))
105 equal(t, true, p.HasReceived("--color"))
106 equal(t, "auto", p.Value("--color"))
107}
108
109func TestArgsParser_BoolValue(t *testing.T) {
110 p := NewArgsParser()

Callers

nothing calls this directly

Calls 7

RegisterBoolMethod · 0.95
ParseMethod · 0.95
BoolMethod · 0.95
HasReceivedMethod · 0.95
ValueMethod · 0.95
NewArgsParserFunction · 0.85
equalFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…