Files
regex-tools/src/regex/execution/request-limits.test.ts

13 lines
432 B
TypeScript

import { describe, expect, it } from "vitest";
import { utf8ByteLength } from "./request-limits";
describe("UTF-8 resource accounting", () => {
it("matches TextEncoder for ASCII, astral characters and lone surrogates", () => {
for (const value of ["", "ASCII", "Bérénice", "😀", "\ud800", "\udc00"]) {
expect(utf8ByteLength(value)).toBe(
new TextEncoder().encode(value).byteLength,
);
}
});
});