mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 07:35:40 +00:00
layout: add test that Flex doesn't allocate
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -47,3 +47,21 @@ func TestStackAllocs(t *testing.T) {
|
||||
t.Errorf("expected no allocs, got %f", allocs)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFlexAllocs(t *testing.T) {
|
||||
var ops op.Ops
|
||||
allocs := testing.AllocsPerRun(1, func() {
|
||||
ops.Reset()
|
||||
gtx := Context{
|
||||
Ops: &ops,
|
||||
}
|
||||
Flex{}.Layout(gtx,
|
||||
Rigid(func(gtx Context) Dimensions {
|
||||
return Dimensions{Size: image.Point{X: 50, Y: 50}}
|
||||
}),
|
||||
)
|
||||
})
|
||||
if allocs != 0 {
|
||||
t.Errorf("expected no allocs, got %f", allocs)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user