| 1 |
// Copyright 2024 The Go Authors. All rights reserved. |
| 2 |
// Use of this source code is governed by a BSD-style |
| 3 |
// license that can be found in the LICENSE file. |
| 4 |
|
| 5 |
package reflect_test |
| 6 |
|
| 7 |
import ( |
| 8 |
"reflect" |
| 9 |
"testing" |
| 10 |
) |
| 11 |
|
| 12 |
// See also runtime_test.TestGroupSizeZero. |
| 13 |
func TestGroupSizeZero(t *testing.T) { |
| 14 |
st := reflect.TypeFor[struct{}]() |
| 15 |
grp := reflect.MapGroupOf(st, st) |
| 16 |
|
| 17 |
// internal/runtime/maps when create pointers to slots, even if slots |
| 18 |
// are size 0. We should have reserved an extra word to ensure that |
| 19 |
// pointers to the zero-size type at the end of group are valid. |
| 20 |
if grp.Size() <= 8 { |
| 21 |
t.Errorf("Group size got %d want >8", grp.Size()) |
| 22 |
} |
| 23 |
} |