Skip to content

Commit f5b4849

Browse files
watildeitaloacasas
authored andcommitted
test: test bottom-up merge sort in URLSearchParams
The bottom-up iterative stable merge sort is called only when the length of provided value is larger than 100. Added a test for it. PR-URL: #11399 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Timothy Gu <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
1 parent ff927b2 commit f5b4849

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

test/parallel/test-whatwg-url-searchparams-sort.js

+15-2
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,25 @@ const { test, assert_array_equals } = common.WPT;
5555
/* eslint-enable */
5656

5757
// Tests below are not from WPT.
58-
;[
58+
59+
// Test bottom-up iterative stable merge sort
60+
const tests = [{input: '', output: []}];
61+
const pairs = [];
62+
for (let i = 10; i < 100; i++) {
63+
pairs.push([`a${i}`, 'b']);
64+
tests[0].output.push([`a${i}`, 'b']);
65+
}
66+
tests[0].input = pairs.sort(() => Math.random() > 0.5)
67+
.map((pair) => pair.join('=')).join('&');
68+
69+
tests.push(
5970
{
6071
'input': 'z=a&=b&c=d',
6172
'output': [['', 'b'], ['c', 'd'], ['z', 'a']]
6273
}
63-
].forEach((val) => {
74+
);
75+
76+
tests.forEach((val) => {
6477
test(() => {
6578
const params = new URLSearchParams(val.input);
6679
let i = 0;

0 commit comments

Comments
 (0)