MCPcopy Index your code
hub / github.com/apache/answer / TestFetchRangedExcerpt

Function TestFetchRangedExcerpt

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

Source from the content-addressed store, hash-verified

153}
154
155func TestFetchRangedExcerpt(t *testing.T) {
156 var (
157 expected,
158 actual string
159 )
160
161 // test english string
162 expected = "hello..."
163 actual = FetchRangedExcerpt("<p>hello world</p>", "...", 0, 5)
164 assert.Equal(t, expected, actual)
165
166 // test string with offset
167 expected = "...llo你好..."
168 actual = FetchRangedExcerpt("<p>hello你好world</p>", "...", 2, 5)
169 assert.Equal(t, expected, actual)
170
171 // test mixed string with emoticon with offset
172 expected = "...你好😂..."
173 actual = FetchRangedExcerpt("<p>hello你好😂world</p>", "...", 5, 3)
174 assert.Equal(t, expected, actual)
175
176 // test mixed string with offset and exceeding limit
177 expected = "...你好😂world"
178 actual = FetchRangedExcerpt("<p>hello你好😂world</p>", "...", 5, 100)
179 assert.Equal(t, expected, actual)
180}
181
182func TestCutLongTitle(t *testing.T) {
183 // Short title, no cutting needed

Callers

nothing calls this directly

Calls 1

FetchRangedExcerptFunction · 0.85

Tested by

no test coverage detected