9 lines
418 B
TypeScript
9 lines
418 B
TypeScript
import { hasValidEncodedIdUtf8Length } from "../src/EncodedFieldGuards";
|
|
|
|
const expect = (value: boolean): void => { if (!value) throw new Error("encoded UTF-8 ID guard failed"); };
|
|
|
|
expect(hasValidEncodedIdUtf8Length("a".repeat(64)));
|
|
expect(!hasValidEncodedIdUtf8Length(""));
|
|
// 33 CJK code points are within a 64-character UI limit but occupy 99 UTF-8 bytes.
|
|
expect(!hasValidEncodedIdUtf8Length("风".repeat(33)));
|