File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -929,6 +929,37 @@ func TestOptLookups(t *testing.T) {
929929 }()
930930 }
931931 }
932+
933+ // with a bunch of option 'a' provided
934+ {
935+ c := in .ParseTheseOrExit ("-a1" , "-a2" , "-a3" )
936+ // use the iterator to break on "2" which should put
937+ // i at index 2 because option a has a default
938+ {
939+ var i int
940+ for v := range GetAllSeq [string ](c , "a" ) {
941+ if v == "2" {
942+ break
943+ }
944+ i ++
945+ }
946+ if i != 2 {
947+ t .Fatalf (`expected to break on "2" and be at index because of default` )
948+ }
949+ }
950+ // trying to cast the first one to anything but a string should panic
951+ {
952+ func () {
953+ defer func () {
954+ gotPanicVal := recover ()
955+ if gotPanicVal == nil {
956+ t .Fatalf ("didn't panic when trying to cast a string arg to an int" )
957+ }
958+ }()
959+ _ = Get [int ](c , "a" )
960+ }()
961+ }
962+ }
932963}
933964
934965func TestArgLookups (t * testing.T ) {
You can’t perform that action at this time.
0 commit comments