1
0
mirror of https://github.com/mum4k/termdash.git synced 2025-04-27 13:48:49 +08:00
termdash/draw/testdraw/testdraw.go
2018-04-07 14:24:55 +02:00

26 lines
737 B
Go

// Package testdraw provides helpers for tests that use the draw package.
package testdraw
import (
"image"
"log"
"github.com/mum4k/termdash/canvas"
"github.com/mum4k/termdash/cell"
"github.com/mum4k/termdash/draw"
)
// MustBox draws box on the canvas or panics.
func MustBox(c *canvas.Canvas, box image.Rectangle, ls draw.LineStyle, opts ...cell.Option) {
if err := draw.Box(c, box, ls, opts...); err != nil {
log.Fatalf("draw.Box => unexpected error: %v", err)
}
}
// MustText draws the text on the canvas or panics.
func MustText(c *canvas.Canvas, text string, tb draw.TextBounds, opts ...cell.Option) {
if err := draw.Text(c, text, tb, opts...); err != nil {
log.Fatalf("draw.Text => unexpected error: %v", err)
}
}