Optimisation & fixes

This commit is contained in:
2026-06-21 12:59:55 +01:00
parent ab65c2e17b
commit d5125a0d62
14 changed files with 1074 additions and 126 deletions
+6 -1
View File
@@ -1,6 +1,7 @@
package ui
import (
"fmt"
"testing"
"github.com/lukaszraczylo/kportal/internal/config"
@@ -140,10 +141,14 @@ func TestTruncate(t *testing.T) {
{"hi!", "hi", 2}, // maxLen <= 3 branch: no ellipsis
{"abcd", "abc", 3}, // maxLen <= 3 branch
{"", "", 5},
{"café-service", "café-...", 8}, // multibyte: count/slice by rune, no mojibake
{"日本語ポッド", "日本...", 5}, // CJK runes truncated cleanly
{"naïve", "naïve", 5}, // exactly maxLen runes (6 bytes) — unchanged
{"abc", "", 0}, // non-positive maxLen
}
for _, tt := range tests {
t.Run(tt.input+"_"+string(rune('0'+tt.maxLen)), func(t *testing.T) {
t.Run(fmt.Sprintf("%s_%d", tt.input, tt.maxLen), func(t *testing.T) {
assert.Equal(t, tt.expected, truncate(tt.input, tt.maxLen))
})
}