import { expect, it } from "vitest"; import { 码点到UTF16, UTF16到码点 } from "../../src/界面/编辑器/字符位置"; // @muse-case {"case_id":"NC-editor-codepoint-selection","environment":"离线组件/实际编辑器;HTTP响应替身不计真实链路","given":"emoji代理对和组合字符","when":"转换编辑器位置与码点位置","then":["合法位置可逆,不截断代理对"],"contract":"docs/系统架构/新版设计/接口契约/正文结构与中文选区.md"} it("NC-editor-codepoint-selection:组合字符与代理对选区转换可逆", () => { const text = "甲🧑‍🏽e\u0301乙"; for (let i = 0; i <= Array.from(text).length; i++) { expect(UTF16到码点(text, 码点到UTF16(text, i))).toBe(i); } expect(() => UTF16到码点(text, 2)).toThrow(); expect(text.slice(码点到UTF16(text, 1), 码点到UTF16(text, 4))).toBe("🧑‍🏽"); });