muse-agent-example/web/tests/编辑/选区转换.test.ts
zizi 98530437f2 W11 编辑器、动态表单与人审工作台:编辑器、动态表单与人审工作台(确认前正文不落正式库)。
按 R2 串行阶段整理提交;包内文件为该阶段交付(含后续小增量),状态以工作包清单为准。
2026-09-10 19:25:41 +08:00

12 lines
533 B
TypeScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { expect, it } from "vitest";
import { 码点到UTF16, UTF16到码点 } from "../../src/界面/编辑器/字符位置";
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("🧑‍🏽");
});