Skip to content

Commit

Permalink
Merge pull request #27 from ydnar/ydnar/wip
Browse files Browse the repository at this point in the history
cm: reorder want, got in tests
  • Loading branch information
ydnar authored Jan 26, 2024
2 parents 94aed29 + 698e2e8 commit 8b28dd5
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions cm/layout_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ func TestFieldAlignment(t *testing.T) {
_ [0][7]byte
u64 uint64
}
if want, got := uintptr(16), unsafe.Sizeof(v1); want != got {
t.Errorf("expected unsafe.Sizeof(v1) == %d, got %d", want, got)
if got, want := unsafe.Sizeof(v1), uintptr(16); got != want {
t.Errorf("expected unsafe.Sizeof(v1) == %d, expected %d", got, want)
}
if want, got := uintptr(8), tinyunsafe.OffsetOf(&v1, &v1.u64); want != got {
t.Errorf("expected unsafe.Offsetof(v1.u64) == %d, got %d", want, got)
if got, want := tinyunsafe.OffsetOf(&v1, &v1.u64), uintptr(8); got != want {
t.Errorf("expected unsafe.Offsetof(v1.u64) == %d, expected %d", got, want)
}

var v2 struct {
Expand All @@ -31,35 +31,35 @@ func TestFieldAlignment(t *testing.T) {
}
u64 uint64
}
if want, got := uintptr(16), unsafe.Sizeof(v2); want != got {
t.Errorf("expected unsafe.Sizeof(v2) == %d, got %d", want, got)
if got, want := unsafe.Sizeof(v2), uintptr(16); got != want {
t.Errorf("expected unsafe.Sizeof(v2) == %d, expected %d", got, want)
}
if want, got := uintptr(8), tinyunsafe.OffsetOf(&v2, &v2.u64); want != got {
t.Errorf("expected unsafe.Offsetof(v2.u64) == %d, got %d", want, got)
if got, want := tinyunsafe.OffsetOf(&v2, &v2.u64), uintptr(8); got != want {
t.Errorf("expected unsafe.Offsetof(v2.u64) == %d, expected %d", got, want)
}

// size 1
var v3 struct {
_ struct{}
b bool // offset 0
}
if want, got := uintptr(1), unsafe.Sizeof(v3); want != got {
t.Errorf("expected unsafe.Sizeof(v3) == %d, got %d", want, got)
if got, want := unsafe.Sizeof(v3), uintptr(1); got != want {
t.Errorf("expected unsafe.Sizeof(v3) == %d, expected %d", got, want)
}
if want, got := uintptr(0), tinyunsafe.OffsetOf(&v3, &v3.b); want != got {
t.Errorf("expected unsafe.Offsetof(v3.b) == %d, got %d", want, got)
if got, want := tinyunsafe.OffsetOf(&v3, &v3.b), uintptr(0); got != want {
t.Errorf("expected unsafe.Offsetof(v3.b) == %d, expected %d", got, want)
}

// size 0
var v4 struct {
_ [0]uint32
b bool // offset 0!
}
if want, got := uintptr(4), unsafe.Sizeof(v4); want != got {
t.Errorf("expected unsafe.Sizeof(v4) == %d, got %d", want, got)
if got, want := unsafe.Sizeof(v4), uintptr(4); got != want {
t.Errorf("expected unsafe.Sizeof(v4) == %d, expected %d", got, want)
}
if want, got := uintptr(0), tinyunsafe.OffsetOf(&v4, &v4.b); want != got {
t.Errorf("expected unsafe.Offsetof(v4.b) == %d, got %d", want, got)
if got, want := tinyunsafe.OffsetOf(&v4, &v4.b), uintptr(0); got != want {
t.Errorf("expected unsafe.Offsetof(v4.b) == %d, expected %d", got, want)
}
}

Expand Down

0 comments on commit 8b28dd5

Please sign in to comment.