@@ -2165,6 +2165,66 @@ func TestParseMultiStringSliceWithDestination(t *testing.T) {
21652165 }).Run ([]string {"run" , "-s" , "10" , "-s" , "20" })
21662166}
21672167
2168+ func TestParseMultiStringSliceDisableSeparator (t * testing.T ) {
2169+ tests := []struct {
2170+ name string
2171+ val * StringSlice
2172+ dest * StringSlice
2173+ disableSep bool
2174+ input []string
2175+ expected []string
2176+ }{
2177+ {
2178+ name : "Basic" ,
2179+ input : []string {"-s" , "10" , "-s" , "20" },
2180+ expected : []string {"10" , "20" },
2181+ },
2182+ {
2183+ name : "Basic Sep" ,
2184+ input : []string {"-s" , "10,20" },
2185+ expected : []string {"10" , "20" },
2186+ },
2187+ {
2188+ name : "Basic Disable Sep" ,
2189+ disableSep : true ,
2190+ input : []string {"-s" , "10,20" },
2191+ expected : []string {"10,20" },
2192+ },
2193+ {
2194+ name : "Basic Disable Sep dest set" ,
2195+ disableSep : true ,
2196+ dest : NewStringSlice ("11" , "22" ),
2197+ input : []string {"-s" , "10,20" },
2198+ expected : []string {"10,20" },
2199+ },
2200+ {
2201+ name : "Basic Disable Sep value set" ,
2202+ disableSep : true ,
2203+ val : NewStringSlice ("11" , "22" ),
2204+ input : []string {"-s" , "10,201" },
2205+ expected : []string {"10,201" },
2206+ },
2207+ }
2208+ for _ , test := range tests {
2209+ t .Run (test .name , func (t * testing.T ) {
2210+ inputs := []string {"run" }
2211+ inputs = append (inputs , test .input ... )
2212+ _ = (& App {
2213+ DisableSliceFlagSeparator : test .disableSep ,
2214+ Flags : []Flag {
2215+ & StringSliceFlag {Name : "serve" , Aliases : []string {"s" }, Destination : test .dest , Value : test .val },
2216+ },
2217+ Action : func (ctx * Context ) error {
2218+ if ! reflect .DeepEqual (ctx .StringSlice ("serve" ), test .expected ) {
2219+ t .Errorf ("Expected: %v != %v" , test .expected , ctx .StringSlice ("serve" ))
2220+ }
2221+ return nil
2222+ },
2223+ }).Run (inputs )
2224+ })
2225+ }
2226+ }
2227+
21682228func TestParseMultiStringSliceWithDestinationAndEnv (t * testing.T ) {
21692229 defer resetEnv (os .Environ ())
21702230 os .Clearenv ()
0 commit comments