1 // Copyright 2018 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.
8 "internal/goexperiment"
15 // Assert that the size of important structures do not change unexpectedly.
17 func TestSizeof(t *testing.T) {
18 const _64bit = unsafe.Sizeof(uintptr(0)) == 8
20 g32bit := uintptr(252)
21 if goexperiment.ExecTracer2 {
25 var tests = []struct {
26 val any // type as a value
27 _32bit uintptr // size on 32bit platforms
28 _64bit uintptr // size on 64bit platforms
30 {runtime.G{}, g32bit, 408}, // g, but exported for testing
31 {runtime.Sudog{}, 56, 88}, // sudog, but exported for testing
34 for _, tt := range tests {
39 got := reflect.TypeOf(tt.val).Size()
41 t.Errorf("unsafe.Sizeof(%T) = %d, want %d", tt.val, got, want)