Skip to content

Commit b1bbbbb

Browse files
committed
add a test
1 parent 21cd789 commit b1bbbbb

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

test/utils.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ import {
99
isSIP,
1010
isTIP,
1111
isSSP,
12+
isHighSurrogate,
13+
isLowSurrogate,
14+
surrogatePairToCodePoint,
1215
} from 'unicode-segmenter/utils';
1316

1417
fc.configureGlobal({
@@ -17,6 +20,25 @@ fc.configureGlobal({
1720
numRuns: 100_000,
1821
});
1922

23+
test('surrogate pairs', () => {
24+
fc.assert(
25+
fc.property(
26+
fc.integer({ min: 0xffff + 1, max: 0xeffff }),
27+
// @ts-ignore
28+
cp => {
29+
let ch = String.fromCodePoint(cp);
30+
let hi = ch.charCodeAt(0);
31+
let lo = ch.charCodeAt(1);
32+
return (
33+
isHighSurrogate(hi) &&
34+
isLowSurrogate(lo) &&
35+
cp === surrogatePairToCodePoint(hi, lo)
36+
);
37+
}
38+
)
39+
)
40+
});
41+
2042
test('isBMP', () => {
2143
fc.assert(
2244
fc.property(

0 commit comments

Comments
 (0)