TestAdjustLineWidth_MultiByteTaskIDFits guards against drift between applyPadding (rune-based) and maxBeforeStatusWidth (formerly byte-based): a byte-based measurement falsely flags overflow for multi-byte taskIDs.
(t *testing.T)
| 274 | // applyPadding (rune-based) and maxBeforeStatusWidth (formerly byte-based): |
| 275 | // a byte-based measurement falsely flags overflow for multi-byte taskIDs. |
| 276 | func TestAdjustLineWidth_MultiByteTaskIDFits(t *testing.T) { |
| 277 | w := &ttyWriter{} |
| 278 | taskID := "Image 测试测试" // 10 runes, 18 bytes |
| 279 | lines := []lineData{{ |
| 280 | taskID: taskID, |
| 281 | status: "Pulling", |
| 282 | }} |
| 283 | |
| 284 | // terminalWidth=30 fits in runes (3+10+1+7+1+4 = 26) but not in bytes |
| 285 | // (3+18+1+7+1+4 = 34), so a byte-based measurement would truncate. |
| 286 | w.adjustLineWidth(lines, 4, 30) |
| 287 | |
| 288 | assert.Equal(t, taskID, lines[0].taskID, |
| 289 | "taskID should not be modified when it fits terminal width in runes") |
| 290 | } |
| 291 | |
| 292 | // TestTruncateLongestTaskID_PreservesValidUTF8 verifies that when truncation |
| 293 | // of a multi-byte UTF-8 taskID is genuinely required, the resulting string |
nothing calls this directly
no test coverage detected