Source file
src/runtime/sizeof_test.go
1
2
3
4
5 package runtime_test
6
7 import (
8 "reflect"
9 "runtime"
10 "testing"
11 "unsafe"
12 )
13
14
15
16 func TestSizeof(t *testing.T) {
17 const _64bit = unsafe.Sizeof(uintptr(0)) == 8
18 var tests = []struct {
19 val any
20 _32bit uintptr
21 _64bit uintptr
22 }{
23 {runtime.G{}, 276, 432},
24 {runtime.Sudog{}, 56, 88},
25 }
26
27 for _, tt := range tests {
28 want := tt._32bit
29 if _64bit {
30 want = tt._64bit
31 }
32 got := reflect.TypeOf(tt.val).Size()
33 if want != got {
34 t.Errorf("unsafe.Sizeof(%T) = %d, want %d", tt.val, got, want)
35 }
36 }
37 }
38
View as plain text