okami.mom/albedo
git clone https://git.nkp.pet/okami.mom/albedo
61c43ca
main
1// Grapheme boundaries and terminal cell arithmetic are not visible through 2// daemon E2E. Verify rendered output rather than the canvas representation. 3package tui 4 5import ( 6"github.com/charmbracelet/x/ansi" 7"strings" 8"testing" 9"unicode/utf8" 10) 11 12func TestAgentCanvasKeepsCellWidthWhenUnicodeLabelsAreOverwritten (t * testing.T ) { 13canvas := newCanvas (16 ,1 ) 14hue := rgb {} 15canvas .put (1 ,0 ,"ζ±δΊ¬e\u0301π©βπ»" ,hue ) 16line := ansi .Strip (canvas .line (0 )) 17if ! strings .Contains (line ,"ζ±δΊ¬e\u0301π©βπ»" )|| ansi .StringWidth (line )!= 16 { 18t .Fatalf ("Unicode label changed canvas width: %q" ,line ) 19 } 20// A graph edge landing in a wide glyph must clear the whole glyph. 21canvas .put (2 ,0 ,"β" ,hue ) 22canvas .put (15 ,0 ,"η" ,hue ) 23line = ansi .Strip (canvas .line (0 )) 24if ansi .StringWidth (line )!= 16 || ! utf8 .ValidString (line )|| strings .Contains (line ,"ζ±" )|| strings .Contains (line ,"η" ) { 25t .Fatalf ("overwriting or clipping a wide glyph corrupted the row: %q" ,line ) 26 } 27} 28 29func TestPythonBurstLabelTruncatesWholeUnicodeCharacters (t * testing.T ) { 30code := strings .Repeat ("#" ,44 )+ "ζ±δΊ¬e\u0301η\nprint('done')" 31label := pyLabel (code ) 32if ! utf8 .ValidString (label )|| ansi .StringWidth (label )> 48 || ! strings .HasSuffix (label ,"β¦" ) { 33t .Fatalf ("truncated label is not valid terminal text: %q" ,label ) 34 } 35}