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

Function TestS2I64

string_to_int64_test.go:58–82  ·  string_to_int64_test.go::TestS2I64
(t *testing.T)

Source from the content-addressed store, hash-verified

56}
57
58func TestS2I64(t *testing.T) {
59 var s2i map[string]int64
60 f := setUpS2I64FlagSet(&s2i)
61
62 vals := map[string]int64{"a": 1, "b": 2, "d": 4, "c": 3}
63 arg := fmt.Sprintf("--s2i=%s", createS2I64Flag(vals))
64 err := f.Parse([]string{arg})
65 if err != nil {
66 t.Fatal("expected no error; got", err)
67 }
68 for k, v := range s2i {
69 if vals[k] != v {
70 t.Fatalf("expected s2i[%s] to be %d but got: %d", k, vals[k], v)
71 }
72 }
73 getS2I, err := f.GetStringToInt64("s2i")
74 if err != nil {
75 t.Fatalf("got error: %v", err)
76 }
77 for k, v := range getS2I {
78 if vals[k] != v {
79 t.Fatalf("expected s2i[%s] to be %d but got: %d from GetStringToInt64", k, vals[k], v)
80 }
81 }
82}
83
84func TestS2I64Default(t *testing.T) {
85 var s2i map[string]int64

Callers

nothing calls this directly

Calls 4

setUpS2I64FlagSetFunction · 0.85
createS2I64FlagFunction · 0.85
GetStringToInt64Method · 0.80
ParseMethod · 0.65

Tested by

no test coverage detected