OLD | NEW |
1 // Copyright 2012 The Go Authors. All rights reserved. | 1 // Copyright 2012 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 package runtime_test | 5 package runtime_test |
6 | 6 |
7 import ( | 7 import ( |
8 "runtime" | 8 "runtime" |
9 "strings" | 9 "strings" |
10 "testing" | 10 "testing" |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 import "strings" | 138 import "strings" |
139 func main() { | 139 func main() { |
140 s0 := strings.Repeat("0", 1<<10) | 140 s0 := strings.Repeat("0", 1<<10) |
141 s1 := strings.Repeat("1", 1<<10) | 141 s1 := strings.Repeat("1", 1<<10) |
142 s2 := strings.Repeat("2", 1<<10) | 142 s2 := strings.Repeat("2", 1<<10) |
143 s3 := strings.Repeat("3", 1<<10) | 143 s3 := strings.Repeat("3", 1<<10) |
144 s := s0 + s1 + s2 + s3 | 144 s := s0 + s1 + s2 + s3 |
145 panic(s) | 145 panic(s) |
146 } | 146 } |
147 ` | 147 ` |
| 148 |
| 149 func TestGostringnocopy(t *testing.T) { |
| 150 max := *runtime.Maxstring |
| 151 b := make([]byte, max+10) |
| 152 for i := uintptr(0); i < max+9; i++ { |
| 153 b[i] = 'a' |
| 154 } |
| 155 _ = runtime.Gostringnocopy(&b[0]) |
| 156 newmax := *runtime.Maxstring |
| 157 if newmax != max+9 { |
| 158 t.Errorf("want %d, got %d", max+9, newmax) |
| 159 } |
| 160 } |
OLD | NEW |