1package chartify 2 3import ( 4 "testing" 5 6 "github.com/google/go-cmp/cmp" 7) 8 9func TestCreateFlagChain(t *testing.T) { 10 testcases := []struct { 11 flag string 12 values []string 13 expect string 14 }{ 15 { 16 flag: "foo", 17 values: []string{"1"}, 18 expect: " --foo 1", 19 }, 20 { 21 flag: "foo", 22 values: []string{"1", "2"}, 23 expect: " --foo 1 --foo 2", 24 }, 25 { 26 flag: "f", 27 values: []string{"a"}, 28 expect: " -f a", 29 }, 30 { 31 flag: "f", 32 values: []string{"a", "b"}, 33 expect: " -f a -f b", 34 }, 35 } 36 37 for i, tc := range testcases { 38 actual := createFlagChain(tc.flag, tc.values) 39 40 if diff := cmp.Diff(tc.expect, actual); diff != "" { 41 t.Errorf("case %d:\n%s", i, diff) 42 } 43 } 44} 45