MCPcopy Create free account
hub / github.com/github/gh-aw / TestTruncate_Unicode

Function TestTruncate_Unicode

pkg/stringutil/stringutil_test.go:178–211  ·  view source on GitHub ↗

Additional edge case tests

(t *testing.T)

Source from the content-addressed store, hash-verified

176// Additional edge case tests
177
178func TestTruncate_Unicode(t *testing.T) {
179 tests := []struct {
180 name string
181 s string
182 maxLen int
183 expected string
184 }{
185 {
186 name: "emoji truncation",
187 s: "Hello 👋 World 🌍",
188 maxLen: 10,
189 expected: "Hello \xf0...", // Truncates in middle of emoji byte sequence
190 },
191 {
192 name: "unicode characters",
193 s: "Café España México",
194 maxLen: 12,
195 expected: "Café Esp...", // Actual behavior
196 },
197 {
198 name: "mixed unicode and ascii",
199 s: "Test-测试-テスト",
200 maxLen: 8,
201 expected: "Test-...",
202 },
203 }
204
205 for _, tt := range tests {
206 t.Run(tt.name, func(t *testing.T) {
207 result := Truncate(tt.s, tt.maxLen)
208 assert.Equal(t, tt.expected, result, "Truncate(%q, %d) should handle unicode input as expected", tt.s, tt.maxLen)
209 })
210 }
211}
212
213func TestNormalizeWhitespace_OnlyWhitespace(t *testing.T) {
214 tests := []struct {

Callers

nothing calls this directly

Calls 2

TruncateFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected