MCPcopy Create free account
hub / github.com/apache/answer / TestCutLongTitle

Function TestCutLongTitle

pkg/htmltext/htmltext_test.go:182–201  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

180}
181
182func TestCutLongTitle(t *testing.T) {
183 // Short title, no cutting needed
184 short := "hello"
185 assert.Equal(t, short, cutLongTitle(short))
186
187 // Exactly max bytes, no cutting needed
188 exact150 := strings.Repeat("a", 150)
189 assert.Len(t, cutLongTitle(exact150), 150)
190
191 // Just over max bytes, should be cut
192 exact151 := strings.Repeat("a", 151)
193 assert.Len(t, cutLongTitle(exact151), 150)
194
195 // Multi-byte rune at boundary gets removed properly
196 asciiPart := strings.Repeat("a", 149) // 149 bytes
197 multiByteChar := "中" // 3 bytes - will span bytes 149-151
198 title := asciiPart + multiByteChar // 152 bytes total
199
200 assert.Equal(t, asciiPart, cutLongTitle(title))
201}
202
203func TestFetchMatchedExcerpt(t *testing.T) {
204 var (

Callers

nothing calls this directly

Calls 1

cutLongTitleFunction · 0.85

Tested by

no test coverage detected