mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 23:55:39 +00:00
060ae1cdf9
They're automatically added by Go 1.17 source formatters. This change adds them all now. Signed-off-by: Elias Naur <mail@eliasnaur.com>
50 lines
848 B
Go
50 lines
848 B
Go
// SPDX-License-Identifier: Unlicense OR MIT
|
|
|
|
//go:build !race
|
|
// +build !race
|
|
|
|
package layout
|
|
|
|
import (
|
|
"image"
|
|
"testing"
|
|
|
|
"gioui.org/op"
|
|
)
|
|
|
|
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)
|
|
}
|
|
}
|
|
|
|
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)
|
|
}
|
|
}
|