vaxis-richtext-test.diff

· erock's pastes · raw

expires: 2025-05-31

 1diff --git a/vxfw/richtext/richtext_test.go b/vxfw/richtext/richtext_test.go
 2index df53cd6..a57b654 100644
 3--- a/vxfw/richtext/richtext_test.go
 4+++ b/vxfw/richtext/richtext_test.go
 5@@ -5,6 +5,7 @@ import (
 6 	"testing"
 7 
 8 	"git.sr.ht/~rockorager/vaxis"
 9+	"git.sr.ht/~rockorager/vaxis/vxfw"
10 	"github.com/stretchr/testify/assert"
11 )
12 
13@@ -127,6 +128,23 @@ func TestFirstLineSegment(t *testing.T) {
14 	}
15 }
16 
17+func TestRichtextSize(t *testing.T) {
18+	app, _ := vxfw.NewApp(vaxis.Options{})
19+	rt := New([]vaxis.Segment{
20+		{Text: "Here is some longish text\n"},
21+		{Text: "Here is some longish text\n"},
22+		{Text: "Here is some longish text\n"},
23+	})
24+	surf, _ := rt.Draw(
25+		vxfw.DrawContext{
26+			Characters: app.Characters,
27+			Max: vxfw.Size{Width: 100, Height: 10},
28+		})
29+	if surf.Size.Height != 3 {
30+		t.Error("wrong size", surf.Size.Height)
31+	}
32+}
33+
34 func TestSoftWrapScanner(t *testing.T) {
35 	tests := []struct {
36 		name     string