Skip to content

Commit 6aa64b2

Browse files
committed
Speed up safeDecodeURIComponent unit tests
1 parent e0f0a68 commit 6aa64b2

File tree

1 file changed

+31
-8
lines changed

1 file changed

+31
-8
lines changed

library/helpers/safeDecodeURIComponent.test.ts

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,14 @@ t.test("compare with original decodeURIComponent", async (t) => {
9999
} catch {
100100
//
101101
}
102-
t.equal(safeDecodeURIComponent(testCase), origResult);
102+
if (safeDecodeURIComponent(testCase) !== origResult) {
103+
t.fail(
104+
`safeDecodeURIComponent("${testCase}") !== decodeURIComponent("${testCase}")`
105+
);
106+
}
103107
}
108+
109+
t.pass("All test cases passed");
104110
});
105111

106112
t.test("benchmark", async (t) => {
@@ -153,11 +159,20 @@ t.test("S15.1.3.2_A1.10_T1", async (t) => {
153159
indexJ <= interval[indexI][1];
154160
indexJ++
155161
) {
156-
t.equal(
157-
safeDecodeURIComponent("%C0%" + String.fromCharCode(indexJ, indexJ)),
162+
if (
163+
safeDecodeURIComponent("%C0%" + String.fromCharCode(indexJ, indexJ)) !==
158164
undefined
159-
);
165+
) {
166+
t.fail(
167+
`safeDecodeURIComponent("%C0%${String.fromCharCode(
168+
indexJ,
169+
indexJ
170+
)}") should be undefined`
171+
);
172+
}
160173
}
174+
175+
t.pass("All test cases passed");
161176
}
162177
});
163178

@@ -174,14 +189,22 @@ t.test("S15.1.3.2_A1.11_T1", async (t) => {
174189
indexJ <= interval[indexI][1];
175190
indexJ++
176191
) {
177-
t.equal(
192+
if (
178193
safeDecodeURIComponent(
179194
"%E0%" + String.fromCharCode(indexJ, indexJ) + "%A0"
180-
),
181-
undefined
182-
);
195+
) !== undefined
196+
) {
197+
t.fail(
198+
`safeDecodeURIComponent("%E0%${String.fromCharCode(
199+
indexJ,
200+
indexJ
201+
)}%A0") should be undefined`
202+
);
203+
}
183204
}
184205
}
206+
207+
t.pass("All test cases passed");
185208
});
186209

187210
t.test("S15.1.3.2_A1.1_T1", async (t) => {

0 commit comments

Comments
 (0)