From 9ee1d18ab59b72b3b77bcc1913c97d6d63fcb5db Mon Sep 17 00:00:00 2001 From: Johan Walles Date: Thu, 23 Mar 2023 22:42:40 +0100 Subject: [PATCH] Add another test Turns out the thing I worried about wasn't moar's fault, but this test is still valid so let's keep it. Ref: https://gitlab.com/gnachman/iterm2/issues/10862 --- twin/screen_test.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/twin/screen_test.go b/twin/screen_test.go index 0649b3e..0d9df7d 100644 --- a/twin/screen_test.go +++ b/twin/screen_test.go @@ -48,3 +48,27 @@ func TestConsumeEncodedEventWithNoInput(t *testing.T) { assert.Assert(t, event == nil) assert.Equal(t, remainder, "") } + +func TestRenderLine(t *testing.T) { + row := []Cell{ + { + Rune: '<', + Style: StyleDefault.WithAttr(AttrReverse), + }, + { + Rune: 'f', + Style: StyleDefault.WithAttr(AttrDim), + }, + } + + rendered, count := renderLine(row) + assert.Equal(t, count, 2) + reset := "" + reversed := "" + notReversed := "" + dim := "" + clearToEol := "" + assert.Equal(t, + strings.ReplaceAll(rendered, "", "ESC"), + strings.ReplaceAll(reset+reversed+"<"+dim+notReversed+"f"+clearToEol+reset, "", "ESC")) +}