(t *testing.T)
| 277 | } |
| 278 | |
| 279 | func TestIsVisibleCanonicalList(t *testing.T) { |
| 280 | t.Parallel() |
| 281 | |
| 282 | // Canonical list — must match site/src/utils/invisibleUnicode.test.ts |
| 283 | // |
| 284 | // Every codepoint that isVisible returns false for is listed |
| 285 | // here, with ranges expanded to individual values. If a |
| 286 | // codepoint is added or removed, this test must be updated. |
| 287 | stripped := []rune{ |
| 288 | 0x00AD, |
| 289 | 0x034F, |
| 290 | 0x061C, |
| 291 | 0x180E, |
| 292 | 0x200B, |
| 293 | // 0x200C (ZWNJ) deliberately NOT stripped. |
| 294 | 0x200D, |
| 295 | 0x200E, |
| 296 | 0x200F, |
| 297 | 0x202A, 0x202B, 0x202C, 0x202D, 0x202E, |
| 298 | 0x2060, 0x2061, 0x2062, 0x2063, 0x2064, |
| 299 | 0x2066, 0x2067, 0x2068, 0x2069, |
| 300 | 0x206A, 0x206B, 0x206C, 0x206D, 0x206E, 0x206F, |
| 301 | 0xFEFF, |
| 302 | 0xFFF9, 0xFFFA, 0xFFFB, |
| 303 | } |
| 304 | |
| 305 | for _, r := range stripped { |
| 306 | input := "a" + string(r) + "b" |
| 307 | got := chatd.SanitizePromptText(input) |
| 308 | require.Equalf(t, "ab", got, "U+%04X should be stripped", r) |
| 309 | } |
| 310 | |
| 311 | // Codepoints that must NOT be stripped. |
| 312 | preserved := []rune{ |
| 313 | 'A', // Normal ASCII. |
| 314 | 'z', // Normal ASCII. |
| 315 | '0', // Digit. |
| 316 | ' ', // Space. |
| 317 | 0x200C, // ZWNJ — required for Persian/Urdu/Kurdish. |
| 318 | 0xE0067, // Tag character — used in subdivision flag emoji. |
| 319 | } |
| 320 | |
| 321 | for _, r := range preserved { |
| 322 | input := "a" + string(r) + "b" |
| 323 | want := "a" + string(r) + "b" |
| 324 | got := chatd.SanitizePromptText(input) |
| 325 | require.Equalf(t, want, got, "U+%04X should be preserved", r) |
| 326 | } |
| 327 | } |
nothing calls this directly
no test coverage detected