12 lines
533 B
TypeScript
12 lines
533 B
TypeScript
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("🧑🏽");
|
||
});
|