(t *testing.T)
| 112 | } |
| 113 | |
| 114 | func TestTruncateText_Long(t *testing.T) { |
| 115 | text := "This is a very long text that needs to be truncated" |
| 116 | result := truncateText(text, 20) |
| 117 | expected := "This is a very lo..." |
| 118 | if result != expected { |
| 119 | t.Errorf("Long text should be truncated: got '%s', want '%s'", result, expected) |
| 120 | } |
| 121 | // Check that result doesn't exceed maxWidth |
| 122 | if len([]rune(result)) > 20 { |
| 123 | t.Errorf("Truncated text exceeds maxWidth: got length %d, want 20", len([]rune(result))) |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | func TestTruncateText_ExactLength(t *testing.T) { |
| 128 | text := "Exactly20Characters!" |
nothing calls this directly
no test coverage detected