Skip to content

Commit 5b239fd

Browse files
committed
Add regression test for Unicode mapping
Verifies that ToUnicodeMap correctly maps Extension B characters to their full Unicode code points using codePointAt See PR #19184
1 parent e9a4830 commit 5b239fd

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

test/unit/clitests.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
"struct_tree_spec.js",
4747
"svg_factory_spec.js",
4848
"text_layer_spec.js",
49+
"to_unicode_map_spec.js",
4950
"type1_parser_spec.js",
5051
"ui_utils_spec.js",
5152
"unicode_spec.js",

test/unit/to_unicode_map_spec.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/* Copyright 2022 Mozilla Foundation
2+
*
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
15+
16+
import { ToUnicodeMap } from "../../src/core/to_unicode_map.js";
17+
18+
describe("ToUnicodeMap", () => {
19+
it("should correctly map Extension B characters using codePointAt", () => {
20+
const cmap = { 0x20: "\uD840\uDC00" }; // Example Extension B character
21+
const toUnicodeMap = new ToUnicodeMap(cmap);
22+
23+
const expected = 0x20000; // Unicode code point for the character
24+
let actual;
25+
toUnicodeMap.forEach((charCode, unicode) => {
26+
if (charCode === "32") {
27+
// 0x20 in decimal
28+
actual = unicode;
29+
}
30+
});
31+
32+
expect(actual).toBe(expected);
33+
});
34+
});

0 commit comments

Comments
 (0)