~eliasnaur/gio

2bdf8c38515c255e55cb0b6128e1375d2f58497a — Elias Naur a month ago acc23a5
layout: add test that Stack doesn't allocate

Signed-off-by: Elias Naur <mail@eliasnaur.com>
1 files changed, 18 insertions(+), 0 deletions(-)

M layout/stack_test.go
M layout/stack_test.go => layout/stack_test.go +18 -0
@@ 29,3 29,21 @@ func TestStack(t *testing.T) {
		t.Errorf("Stack ignored Expanded size, got %v expected %v", got, exp)
	}
}

func TestStackAllocs(t *testing.T) {
	var ops op.Ops
	allocs := testing.AllocsPerRun(1, func() {
		ops.Reset()
		gtx := Context{
			Ops: &ops,
		}
		Stack{}.Layout(gtx,
			Stacked(func(gtx Context) Dimensions {
				return Dimensions{Size: image.Point{X: 50, Y: 50}}
			}),
		)
	})
	if allocs != 0 {
		t.Errorf("expected no allocs, got %f", allocs)
	}
}