Improve type handling in Seq
authorbep <bjorn.erik.pedersen@gmail.com>
Wed, 18 Mar 2015 10:10:04 +0000 (11:10 +0100)
committerbep <bjorn.erik.pedersen@gmail.com>
Wed, 18 Mar 2015 10:30:37 +0000 (11:30 +0100)
helpers/general.go
helpers/general_test.go

index a218cbd5db7c6899a6273e521753d702046d2327..f7ff3381d5e0e7fa6c0a6360906589f41e4ce885 100644 (file)
@@ -175,6 +175,10 @@ func Seq(args ...interface{}) ([]int, error) {
 
        intArgs := cast.ToIntSlice(args)
 
+       if len(intArgs) < 1 || len(intArgs) > 3 {
+               return nil, errors.New("Invalid argument(s) to Seq")
+       }
+
        var inc int = 1
        var last int
        var first = intArgs[0]
index 9d28d214c2a5269cb146fbffdd45e0a5433b9c78..4a20077af0367bde5e23d6e051bd48752308a5d0 100644 (file)
@@ -154,7 +154,7 @@ func TestSeq(t *testing.T) {
                {[]interface{}{2, 1, 1, 1}, false},
                {[]interface{}{2001}, false},
                {[]interface{}{}, false},
-               {[]interface{}{t}, []int{}},
+               {[]interface{}{t}, false},
                {nil, false},
        } {