(t *testing.T)
| 153 | } |
| 154 | |
| 155 | func 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 | |
| 182 | func TestCutLongTitle(t *testing.T) { |
| 183 | // Short title, no cutting needed |
nothing calls this directly
no test coverage detected