summaryrefslogtreecommitdiff
path: root/src/pkg/reflect/all_test.go
diff options
context:
space:
mode:
authorIngo Oeser <ingo@jimdo.com>2013-06-14 23:22:50 +0200
committerIngo Oeser <ingo@jimdo.com>2013-06-14 23:22:50 +0200
commit09f84a75bc63a6316d575f531489d69ec8ade2e8 (patch)
treeb74a4dcecf087639a6898acb55c71dae1e54b299 /src/pkg/reflect/all_test.go
parentefcc50dfdc94c82ee0292bf71992ecb7c0123061 (diff)
downloadgolang-09f84a75bc63a6316d575f531489d69ec8ade2e8.tar.gz
Imported Upstream version 1.1.1upstream/1.1.1
Diffstat (limited to 'src/pkg/reflect/all_test.go')
-rw-r--r--src/pkg/reflect/all_test.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/pkg/reflect/all_test.go b/src/pkg/reflect/all_test.go
index 56cb315ad..a61f66308 100644
--- a/src/pkg/reflect/all_test.go
+++ b/src/pkg/reflect/all_test.go
@@ -3032,6 +3032,25 @@ func TestSliceOf(t *testing.T) {
checkSameType(t, Zero(SliceOf(TypeOf(T1(1)))).Interface(), []T1{})
}
+func TestSliceOverflow(t *testing.T) {
+ // check that MakeSlice panics when size of slice overflows uint
+ const S = 1e6
+ s := uint(S)
+ l := (1<<(unsafe.Sizeof((*byte)(nil))*8)-1)/s + 1
+ if l*s >= s {
+ t.Fatal("slice size does not overflow")
+ }
+ var x [S]byte
+ st := SliceOf(TypeOf(x))
+ defer func() {
+ err := recover()
+ if err == nil {
+ t.Fatal("slice overflow does not panic")
+ }
+ }()
+ MakeSlice(st, int(l), int(l))
+}
+
func TestSliceOfGC(t *testing.T) {
type T *uintptr
tt := TypeOf(T(nil))