mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 07:35:40 +00:00
80196f3c3e
Before this change, a macro not Stop'ed would result in an endless loop during op decoding. Signed-off-by: Elias Naur <mail@eliasnaur.com>
37 lines
626 B
Go
37 lines
626 B
Go
// SPDX-License-Identifier: Unlicense OR MIT
|
|
|
|
package op
|
|
|
|
import (
|
|
"image"
|
|
"testing"
|
|
|
|
"gioui.org/internal/ops"
|
|
)
|
|
|
|
func TestTransformChecks(t *testing.T) {
|
|
defer func() {
|
|
if err := recover(); err == nil {
|
|
t.Error("cross-macro Pop didn't panic")
|
|
}
|
|
}()
|
|
var ops Ops
|
|
trans := Offset(image.Point{}).Push(&ops)
|
|
Record(&ops)
|
|
trans.Pop()
|
|
}
|
|
|
|
func TestIncompleteMacroReader(t *testing.T) {
|
|
var o Ops
|
|
// Record, but don't Stop it.
|
|
Record(&o)
|
|
Offset(image.Point{}).Push(&o)
|
|
|
|
var r ops.Reader
|
|
|
|
r.Reset(&o.Internal)
|
|
if _, more := r.Decode(); more {
|
|
t.Error("decoded an operation from a semantically empty Ops")
|
|
}
|
|
}
|