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: https://github.com/nodejs/node/pull/11399 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
This commit is contained in:
parent
e18ebe8354
commit
1b31ca6cca
@ -55,12 +55,25 @@ const { test, assert_array_equals } = common.WPT;
|
|||||||
/* eslint-enable */
|
/* eslint-enable */
|
||||||
|
|
||||||
// Tests below are not from WPT.
|
// Tests below are not from WPT.
|
||||||
;[
|
|
||||||
|
// Test bottom-up iterative stable merge sort
|
||||||
|
const tests = [{input: '', output: []}];
|
||||||
|
const pairs = [];
|
||||||
|
for (let i = 10; i < 100; i++) {
|
||||||
|
pairs.push([`a${i}`, 'b']);
|
||||||
|
tests[0].output.push([`a${i}`, 'b']);
|
||||||
|
}
|
||||||
|
tests[0].input = pairs.sort(() => Math.random() > 0.5)
|
||||||
|
.map((pair) => pair.join('=')).join('&');
|
||||||
|
|
||||||
|
tests.push(
|
||||||
{
|
{
|
||||||
'input': 'z=a&=b&c=d',
|
'input': 'z=a&=b&c=d',
|
||||||
'output': [['', 'b'], ['c', 'd'], ['z', 'a']]
|
'output': [['', 'b'], ['c', 'd'], ['z', 'a']]
|
||||||
}
|
}
|
||||||
].forEach((val) => {
|
);
|
||||||
|
|
||||||
|
tests.forEach((val) => {
|
||||||
test(() => {
|
test(() => {
|
||||||
const params = new URLSearchParams(val.input);
|
const params = new URLSearchParams(val.input);
|
||||||
let i = 0;
|
let i = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user