MCPcopy
hub / github.com/mislav/hub / TestArgsParser

Function TestArgsParser

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

Source from the content-addressed store, hash-verified

14}
15
16func TestArgsParser(t *testing.T) {
17 p := NewArgsParser()
18 p.RegisterValue("--hello", "-e")
19 p.RegisterValue("--origin", "-o")
20 args := []string{"--hello", "world", "one", "--", "--two"}
21 rest, err := p.Parse(args)
22 equal(t, nil, err)
23 equal(t, []string{"one", "--two"}, rest)
24 equal(t, "world", p.Value("--hello"))
25 equal(t, true, p.HasReceived("--hello"))
26 equal(t, "", p.Value("-e"))
27 equal(t, false, p.HasReceived("-e"))
28 equal(t, "", p.Value("--origin"))
29 equal(t, false, p.HasReceived("--origin"))
30 equal(t, []int{2, 4}, p.PositionalIndices)
31}
32
33func TestArgsParser_RepeatedInvocation(t *testing.T) {
34 p := NewArgsParser()

Callers

nothing calls this directly

Calls 6

RegisterValueMethod · 0.95
ParseMethod · 0.95
ValueMethod · 0.95
HasReceivedMethod · 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…