MCPcopy
hub / github.com/spf13/pflag / TestSS

Function TestSS

string_slice_test.go:59–84  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

57}
58
59func TestSS(t *testing.T) {
60 var ss []string
61 f := setUpSSFlagSet(&ss)
62
63 vals := []string{"one", "two", "4", "3"}
64 arg := fmt.Sprintf("--ss=%s", strings.Join(vals, ","))
65 err := f.Parse([]string{arg})
66 if err != nil {
67 t.Fatal("expected no error; got", err)
68 }
69 for i, v := range ss {
70 if vals[i] != v {
71 t.Fatalf("expected ss[%d] to be %s but got: %s", i, vals[i], v)
72 }
73 }
74
75 getSS, err := f.GetStringSlice("ss")
76 if err != nil {
77 t.Fatal("got an error from GetStringSlice():", err)
78 }
79 for i, v := range getSS {
80 if vals[i] != v {
81 t.Fatalf("expected ss[%d] to be %s from GetStringSlice but got: %s", i, vals[i], v)
82 }
83 }
84}
85
86func TestSSDefault(t *testing.T) {
87 var ss []string

Callers

nothing calls this directly

Calls 3

setUpSSFlagSetFunction · 0.85
GetStringSliceMethod · 0.80
ParseMethod · 0.65

Tested by

no test coverage detected