3 // Copyright 2014 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file.
13 bytes = []byte{1, 2, 3, 4, 5}
14 ints = []int32{1, 2, 3, 4, 5}
28 func checkString(desc, s string) {
29 p1 := *(*uintptr)(unsafe.Pointer(&s))
30 p2 := *(*uintptr)(unsafe.Pointer(&hello))
33 println("string", desc, "has invalid base")
37 func checkBytes(desc string, s []byte) {
38 p1 := *(*uintptr)(unsafe.Pointer(&s))
39 p2 := *(*uintptr)(unsafe.Pointer(&bytes))
41 println("byte slice", desc, "has invalid base")
45 func checkInts(desc string, s []int32) {
46 p1 := *(*uintptr)(unsafe.Pointer(&s))
47 p2 := *(*uintptr)(unsafe.Pointer(&ints))
49 println("int slice", desc, "has invalid base")
57 checkString("x[5:]", x[5:])
58 checkString("x[five:]", x[five:])
59 checkString("x[5:five]", x[5:five])
60 checkString("x[five:5]", x[five:5])
61 checkString("x[five:five]", x[five:five])
62 checkString("x[1:][2:][2:]", x[1:][2:][2:])
64 checkString("y[1:]", y[1:])
69 checkBytes("x[5:]", x[5:])
70 checkBytes("x[five:]", x[five:])
71 checkBytes("x[5:five]", x[5:five])
72 checkBytes("x[five:5]", x[five:5])
73 checkBytes("x[five:five]", x[five:five])
74 checkBytes("x[1:][2:][2:]", x[1:][2:][2:])
76 checkBytes("y[1:]", y[1:])
81 checkInts("x[5:]", x[5:])
82 checkInts("x[five:]", x[five:])
83 checkInts("x[5:five]", x[5:five])
84 checkInts("x[five:5]", x[five:5])
85 checkInts("x[five:five]", x[five:five])
86 checkInts("x[1:][2:][2:]", x[1:][2:][2:])
88 checkInts("y[1:]", y[1:])