dwc1997
f92ec2d4e8
test(shared): add unit tests for surrogate-safe UTF-16 string slicing helpers (#97805)
* test(shared): add unit tests for surrogate-safe UTF-16 string slicing helpers
Add unit tests for sliceUtf16Safe and truncateUtf16Safe functions in
src/shared/utf16-slice.ts to verify UTF-16 string slicing behavior.
Tests cover:
- sliceUtf16Safe slices ASCII string normally
- sliceUtf16Safe handles negative start/end
- sliceUtf16Safe handles start/end beyond length
- sliceUtf16Safe swaps start and end when start > end
- sliceUtf16Safe preserves emoji with surrogate pairs
- sliceUtf16Safe avoids splitting surrogate pair at start/end
- truncateUtf16Safe returns input when shorter than limit
- truncateUtf16Safe truncates when longer than limit
- truncateUtf16Safe handles zero/negative limit
- truncateUtf16Safe floors decimal limit
- truncateUtf16Safe preserves emoji with surrogate pairs
- truncateUtf16Safe avoids splitting surrogate pair
* fix: replace tautological surrogate assertions with exact output checks
Replace vague 'result.length >= 0' assertions with exact expected output
checks for surrogate pair boundary cases. The helper returns empty string
when slicing at surrogate pair boundaries.
2026-06-29 10:50:58 -07:00
..
2026-06-28 15:49:03 -07:00
2026-06-22 14:08:46 +08:00
2026-06-03 15:20:39 -07:00
2026-06-04 20:02:33 -04:00
2026-06-03 15:20:39 -07:00
2026-06-23 03:31:32 +08:00
2026-06-11 11:15:47 +09:00
2026-06-10 08:08:35 -07:00
2026-06-28 11:06:20 -07:00
2026-06-04 20:02:33 -04:00
2026-06-04 20:02:33 -04:00
2026-06-04 20:02:33 -04:00
2026-06-17 15:59:58 +08:00
2026-06-09 16:45:14 +09:00
2026-06-17 15:59:58 +08:00
2026-06-04 20:02:33 -04:00
2026-05-31 22:32:28 -04:00
2026-06-04 20:02:33 -04:00
2026-06-04 20:02:33 -04:00
2026-06-22 10:07:09 -07:00
2026-06-22 10:07:09 -07:00
2026-06-28 13:48:24 -07:00
2026-06-28 13:48:24 -07:00
2026-05-31 22:32:28 -04:00
2026-06-04 20:02:33 -04:00
2026-06-10 08:08:35 -07:00
2026-06-04 20:02:33 -04:00
2026-06-04 20:02:33 -04:00
2026-06-04 20:02:33 -04:00
2026-05-31 14:37:41 +01:00
2026-06-04 20:02:33 -04:00
2026-06-04 20:02:33 -04:00
2026-06-22 18:56:01 +08:00
2026-06-22 18:56:01 +08:00
2026-06-04 20:02:33 -04:00
2026-06-04 20:02:33 -04:00
2026-06-04 20:02:33 -04:00
2026-06-17 16:03:38 +08:00
2026-06-23 08:04:35 +08:00
2026-06-22 09:37:09 +08:00
2026-06-04 20:02:33 -04:00
2026-06-04 20:02:33 -04:00
2026-06-04 20:02:33 -04:00
2026-06-04 20:02:33 -04:00
2026-06-04 20:02:33 -04:00
2026-06-04 20:02:33 -04:00
2026-06-04 20:02:33 -04:00
2026-06-03 15:20:39 -07:00
2026-06-04 20:02:33 -04:00
2026-05-31 22:32:28 -04:00
2026-06-23 07:56:52 +08:00
2026-06-04 20:02:33 -04:00
2026-06-11 01:10:20 +09:00
2026-06-11 01:10:20 +09:00
2026-06-04 20:02:33 -04:00
2026-06-04 20:02:33 -04:00
2026-06-17 16:03:38 +08:00
2026-06-04 20:02:33 -04:00
2026-06-21 14:23:43 +08:00
2026-05-31 22:32:28 -04:00
2026-06-10 08:08:35 -07:00
2026-06-03 15:20:39 -07:00
2026-06-23 07:45:50 +08:00
2026-06-24 15:51:55 +08:00
2026-06-24 15:51:55 +08:00
2026-06-29 10:36:29 -07:00
2026-06-29 10:36:29 -07:00
2026-06-13 17:40:18 -07:00
2026-06-19 09:41:52 +08:00
2026-06-19 09:41:52 +08:00
2026-06-17 16:03:38 +08:00
2026-06-04 20:02:33 -04:00
2026-06-04 20:02:33 -04:00
2026-06-23 03:46:22 +08:00
2026-06-22 17:49:19 +00:00
2026-06-04 20:02:33 -04:00
2026-06-04 20:02:33 -04:00
2026-06-17 16:06:41 +08:00
2026-06-04 20:02:33 -04:00
2026-06-04 20:02:33 -04:00
2026-06-03 15:20:39 -07:00
2026-06-04 20:02:33 -04:00
2026-06-04 20:02:33 -04:00
2026-06-19 21:36:52 +08:00
2026-06-19 21:36:52 +08:00
2026-06-03 15:20:39 -07:00
2026-06-03 15:20:39 -07:00
2026-06-04 20:02:33 -04:00
2026-06-03 15:20:39 -07:00
2026-06-03 15:20:39 -07:00
2026-06-03 15:20:39 -07:00
2026-06-04 20:02:33 -04:00
2026-06-04 20:02:33 -04:00
2026-06-25 13:10:35 -07:00
2026-06-04 20:02:33 -04:00
2026-06-03 15:20:39 -07:00
2026-06-28 13:58:58 -07:00
2026-06-28 13:58:58 -07:00
2026-06-04 20:02:33 -04:00
2026-06-04 20:02:33 -04:00
2026-06-04 20:02:33 -04:00
2026-06-17 18:56:25 +08:00
2026-06-04 20:02:33 -04:00
2026-06-03 15:20:39 -07:00
2026-06-17 16:06:41 +08:00
2026-06-04 20:02:33 -04:00
2026-06-04 20:02:33 -04:00
2026-06-04 20:02:33 -04:00
2026-06-29 10:50:58 -07:00
2026-06-27 08:10:06 +08:00