-
Notifications
You must be signed in to change notification settings - Fork 319
Expand file tree
/
Copy pathwhitespace_test.go
More file actions
52 lines (44 loc) · 1.17 KB
/
whitespace_test.go
File metadata and controls
52 lines (44 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package lipgloss
import (
"testing"
"time"
)
func TestWhitespaceRenderWithTab(t *testing.T) {
// This test verifies that rendering whitespace with tab characters
// doesn't cause an infinite loop (issue #108)
done := make(chan bool, 1)
go func() {
ws := newWhitespace(WithWhitespaceChars("\t"))
_ = ws.render(10)
done <- true
}()
select {
case <-done:
// Success - render completed
case <-time.After(2 * time.Second):
t.Fatal("whitespace.render() with tab character caused infinite loop")
}
}
func TestWhitespaceRenderWithZeroWidthChar(t *testing.T) {
// Test with zero-width joiner (another zero-width character)
done := make(chan bool, 1)
go func() {
ws := newWhitespace(WithWhitespaceChars("\u200d")) // zero-width joiner
_ = ws.render(5)
done <- true
}()
select {
case <-done:
// Success
case <-time.After(2 * time.Second):
t.Fatal("whitespace.render() with zero-width character caused infinite loop")
}
}
func TestWhitespaceRenderNormal(t *testing.T) {
// Verify normal behavior still works
ws := newWhitespace(WithWhitespaceChars("*"))
result := ws.render(5)
if len(result) != 5 {
t.Errorf("expected 5 characters, got %d", len(result))
}
}