github.com/utopiagio/gio@v0.0.8/op/op_test.go (about)

     1  // SPDX-License-Identifier: Unlicense OR MIT
     2  
     3  package op
     4  
     5  import (
     6  	"image"
     7  	"testing"
     8  
     9  	"github.com/utopiagio/gio/internal/ops"
    10  )
    11  
    12  func TestTransformChecks(t *testing.T) {
    13  	defer func() {
    14  		if err := recover(); err == nil {
    15  			t.Error("cross-macro Pop didn't panic")
    16  		}
    17  	}()
    18  	var ops Ops
    19  	trans := Offset(image.Point{}).Push(&ops)
    20  	Record(&ops)
    21  	trans.Pop()
    22  }
    23  
    24  func TestIncompleteMacroReader(t *testing.T) {
    25  	var o Ops
    26  	// Record, but don't Stop it.
    27  	Record(&o)
    28  	Offset(image.Point{}).Push(&o)
    29  
    30  	var r ops.Reader
    31  
    32  	r.Reset(&o.Internal)
    33  	if _, more := r.Decode(); more {
    34  		t.Error("decoded an operation from a semantically empty Ops")
    35  	}
    36  }