mirror of
https://github.com/morluto/rea.git
synced 2026-11-12 01:41:21 +00:00
Derive ordinary plist depth from existing JSON result capacity while preserving archive limits. Decode supported XML and safe JSON directly from owned source bytes; retain conversion for OpenStep, unsafe numeric classification and unsupported encodings. Preserve typed scalar facts, truthful provenance, cleanup ownership and explicit capacity recovery.
42 lines
1.1 KiB
TypeScript
42 lines
1.1 KiB
TypeScript
import { expect, it } from "vitest";
|
|
|
|
import {
|
|
decodeXmlPlistText,
|
|
XmlPlistTextDecodeError,
|
|
} from "./propertyListXmlText.js";
|
|
|
|
it.each([
|
|
[
|
|
Buffer.from(
|
|
'<?xml version="1.0" encoding="ISO-8859-1"?><plist><string>caf\xe9</string></plist>',
|
|
"latin1",
|
|
),
|
|
"unsupported-encoding",
|
|
],
|
|
[
|
|
Buffer.from(
|
|
'<?xml version="1.0" encoding="UTF-8"?><plist><string>\xff</string></plist>',
|
|
"latin1",
|
|
),
|
|
"invalid-bytes",
|
|
],
|
|
[Buffer.from([0xff, 0xfe, 0, 0, 0x3c, 0, 0, 0]), "unsupported-encoding"],
|
|
[Buffer.from([0, 0, 0xfe, 0xff, 0, 0, 0, 0x3c]), "unsupported-encoding"],
|
|
[
|
|
Buffer.from('<?xml version="1.0" encoding="UTF-16"?><plist/>'),
|
|
"encoding-mismatch",
|
|
],
|
|
[
|
|
Buffer.from('<?xml version="1.0" encoding="ISO-8859-1"?><plist/>'),
|
|
"unsupported-encoding",
|
|
],
|
|
[Buffer.from([0xff, 0xfe, 0x3c]), "invalid-bytes"],
|
|
] as const)("tags XML decoding failures as %s", (bytes, reason) => {
|
|
expect(() => decodeXmlPlistText(bytes)).toThrow(
|
|
expect.objectContaining({
|
|
name: "XmlPlistTextDecodeError",
|
|
reason,
|
|
} satisfies Partial<XmlPlistTextDecodeError>),
|
|
);
|
|
});
|