Skip to content

Commit

Permalink
Update hexToString.test.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
Gigabyte5671 authored Dec 26, 2022
1 parent 4c37f5f commit 965db9b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tests/hexToString.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import { performance } from 'perf_hooks';
import { hexToString } from '../functions/Utils.js';

const data = `[198,1,3,0,199,2,139,125,0,0,40,2,2,0,0,0,233,0,1,0,38,0,133,3,85,39,0,0,238,6,0,0,0,0,199,2,139,125,0,0,8,0,0,0,0,0,0,0,0,0,255,2,0,0,0,0,237,2,0,0,0,0,216,2,5,0,0,0,236,2,4,0,0,0,215,2,14,0,0,0,175,2,1,0,110,19,0,1,0,121,170,0,1,0,121,166,1,1,0,110,241,6,0,0,112,65,3,7,0,67,3,1,0,0,0,68,3,0,0,0,0,89,2,1,0,0,0,253,3,101,0,0,0,179,2,6,29,0,0,72,4,4,0,0,0,214,2,28,0,0,0,245,6,0,0,0,0,153,2,0,0,0,0,152,2,0,0,0,0,191,6,50,0,0,0,156,6,0,155,6,0,0,3,12,0,71,114,121,111,122,115,83,101,114,118,101,114,164,1,10,0,67,84,70,32,67,117,115,116,111,109,178,2,182,5,0,0,181,2,80,223,137,0,71,3,1,0,0,0,244,2,92,2,0,0,53,0,0,0,0,0,151,1,2,0,0,0,50,1,1,0,13,0,72,3,57,5,0,0,74,3,4,0,71,105,103,97,42,4,7,0,0,0,88,5,0,0,0,0,99,3,0,0,0,0,21,6,0,0,0,0,82,4,1,0,0,0,37,2,16,190,36,0,150,2,31,0,0,0,238,6,0,0,0,0,46,4,0,0,112,66,47,4,0,0,160,65,245,3,0,0,0,64,70,2,2,0,35,42,95,211,127,133,9,0,0,0,61,0,0,0]`;

const expectedResult = `c6010300c7028b7d0000280202000000e90001002600850355270000ee0600000000c7028b7d000008000000000000000000ff0200000000ed0200000000d80205000000ec0204000000d7020e000000af0201006e1300010079aa00010079a60101006ef10600007041030700430301000000440300000000590201000000fd0365000000b302061d0000480404000000d6021c000000f50600000000990200000000980200000000bf06320000009c06009b060000030c004772796f7a73536572766572a4010a0043544620437573746f6db202b6050000b50250df8900470301000000f4025c020000350000000000970102000000320101000d004803390500004a030400476967612a0407000000580500000000630300000000150600000000520401000000250210be240096021f000000ee06000000002e04000070422f040000a041f5030000004046020200232a5fd37f85090000003d000000`;

// <Test>
const startTime = performance.now();
const string = hexToString(Uint8Array.from(JSON.parse(data)));
const endTime = performance.now();
// </Test>

if (!string) {
throw new Error('Output is null.');
Expand All @@ -18,4 +23,4 @@ if (string !== expectedResult) {
throw new Error('Output value is incorrect.');
}

console.log('Test passed.');
console.log(`Passed in ${endTime - startTime}ms.`);

0 comments on commit 965db9b

Please sign in to comment.