Check that structure alignment & offsets viewed through reflect agree with those from the compiler itself.
(t *testing.T)
| 1340 | // Check that structure alignment & offsets viewed through reflect agree with those |
| 1341 | // from the compiler itself. |
| 1342 | func TestAlignment(t *testing.T) { |
| 1343 | type T1inner struct { |
| 1344 | a int |
| 1345 | } |
| 1346 | type T1 struct { |
| 1347 | T1inner |
| 1348 | f int |
| 1349 | } |
| 1350 | type T2inner struct { |
| 1351 | a, b int |
| 1352 | } |
| 1353 | type T2 struct { |
| 1354 | T2inner |
| 1355 | f int |
| 1356 | } |
| 1357 | |
| 1358 | x := T1{T1inner{2}, 17} |
| 1359 | check2ndField(x, uintptr(unsafe.Pointer(&x.f))-uintptr(unsafe.Pointer(&x)), t) |
| 1360 | |
| 1361 | x1 := T2{T2inner{2, 3}, 17} |
| 1362 | check2ndField(x1, uintptr(unsafe.Pointer(&x1.f))-uintptr(unsafe.Pointer(&x1)), t) |
| 1363 | } |
| 1364 | |
| 1365 | func Nil(a any, t *testing.T) { |
| 1366 | n := ValueOf(a).Field(0) |
nothing calls this directly
no test coverage detected