Add regression test for Unicode mapping

Verifies that ToUnicodeMap correctly maps Extension B characters to their full Unicode code points using codePointAt

See PR https://github.com/mozilla/pdf.js/pull/19184
This commit is contained in:
maettuu 2025-08-06 12:35:49 +02:00
parent e9a483014d
commit 2d8dfb0b62
2 changed files with 34 additions and 0 deletions

View File

@ -46,6 +46,7 @@
"struct_tree_spec.js",
"svg_factory_spec.js",
"text_layer_spec.js",
"to_unicode_map_spec.js",
"type1_parser_spec.js",
"ui_utils_spec.js",
"unicode_spec.js",

View File

@ -0,0 +1,33 @@
/* Copyright 2025 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { ToUnicodeMap } from "../../src/core/to_unicode_map.js";
describe("ToUnicodeMap", () => {
it("should correctly map Extension B characters using codePointAt", () => {
const cmap = { 0x20: "\uD840\uDC00" }; // Example Extension B character
const toUnicodeMap = new ToUnicodeMap(cmap);
const expected = 0x20000; // Unicode code point for the character
let actual;
toUnicodeMap.forEach((charCode, unicode) => {
if (charCode === (0x20).toString()) {
actual = unicode;
}
});
expect(actual).toBe(expected);
});
});