Skip to content

Commit 003b257

Browse files
committed
tests: TestReflectArraySize
1 parent 7aec0a6 commit 003b257

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

tests/arrays_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package tests
33
import (
44
"reflect"
55
"testing"
6+
"unsafe"
67
)
78

89
func TestArrayPointer(t *testing.T) {
@@ -76,3 +77,10 @@ func TestArrayPointer(t *testing.T) {
7677

7778
})
7879
}
80+
81+
func TestReflectArraySize(t *testing.T) {
82+
want := unsafe.Sizeof(int(0)) * 8
83+
if got := reflect.TypeOf([8]int{}).Size(); got != want {
84+
t.Errorf("array type size gave %v, want %v", got, want)
85+
}
86+
}

0 commit comments

Comments
 (0)