(t *testing.T)
| 16 | ) |
| 17 | |
| 18 | func TestTruncateLabel(t *testing.T) { |
| 19 | t.Parallel() |
| 20 | |
| 21 | tests := []struct { |
| 22 | name string |
| 23 | input string |
| 24 | maxLen int |
| 25 | want string |
| 26 | }{ |
| 27 | {name: "Empty", input: "", maxLen: 10, want: ""}, |
| 28 | {name: "WhitespaceOnly", input: " \t\n ", maxLen: 10, want: ""}, |
| 29 | {name: "ShortText", input: "hello world", maxLen: 20, want: "hello world"}, |
| 30 | {name: "ExactLength", input: "abcde", maxLen: 5, want: "abcde"}, |
| 31 | {name: "LongTextTruncated", input: "abcdefghij", maxLen: 5, want: "abcd…"}, |
| 32 | {name: "NegativeMaxLen", input: "hello", maxLen: -1, want: ""}, |
| 33 | {name: "ZeroMaxLen", input: "hello", maxLen: 0, want: ""}, |
| 34 | {name: "SingleRuneLimit", input: "hello", maxLen: 1, want: "…"}, |
| 35 | {name: "MultipleWhitespaceRuns", input: " hello world \t again ", maxLen: 100, want: "hello world again"}, |
| 36 | {name: "UnicodeRunes", input: "こんにちは世界", maxLen: 3, want: "こん…"}, |
| 37 | } |
| 38 | |
| 39 | for _, tc := range tests { |
| 40 | t.Run(tc.name, func(t *testing.T) { |
| 41 | t.Parallel() |
| 42 | got := chatdebug.TruncateLabel(tc.input, tc.maxLen) |
| 43 | require.Equal(t, tc.want, got) |
| 44 | require.LessOrEqual(t, utf8.RuneCountInString(got), max(tc.maxLen, 0)) |
| 45 | }) |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | func TestSeedSummary(t *testing.T) { |
| 50 | t.Parallel() |
nothing calls this directly
no test coverage detected