TestTruncateLongestTaskID_PreservesValidUTF8 verifies that when truncation of a multi-byte UTF-8 taskID is genuinely required, the resulting string remains valid UTF-8. Byte-indexed slicing can land mid-rune and emit replacement characters (�) into the rendered output.
(t *testing.T)
| 294 | // remains valid UTF-8. Byte-indexed slicing can land mid-rune and emit |
| 295 | // replacement characters (�) into the rendered output. |
| 296 | func TestTruncateLongestTaskID_PreservesValidUTF8(t *testing.T) { |
| 297 | taskID := "Image 测试测试测试测试" // 14 runes, 30 bytes |
| 298 | lines := []lineData{{taskID: taskID}} |
| 299 | |
| 300 | truncateLongestTaskID(lines, 8, 10) |
| 301 | |
| 302 | assert.Assert(t, utf8.ValidString(lines[0].taskID), |
| 303 | "truncated taskID must remain valid UTF-8, got %q", lines[0].taskID) |
| 304 | assert.Assert(t, strings.HasSuffix(lines[0].taskID, "..."), |
| 305 | "truncated taskID should end with ..., got %q", lines[0].taskID) |
| 306 | } |
| 307 | |
| 308 | // TestTruncateProgressSize_PicksWidestLine verifies that dropping the size |
| 309 | // suffix targets the line currently driving maxBeforeStatusWidth (the only |
nothing calls this directly
no test coverage detected