feat: implement debug node
All checks were successful
🚀 Lint & Test & Deploy / release (pull_request) Successful in 3m53s
All checks were successful
🚀 Lint & Test & Deploy / release (pull_request) Successful in 3m53s
Closes #39
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
import { expect, test } from 'vitest';
|
||||
import { concatEncodedArrays, decodeNestedArray, encodeNestedArray } from './flatTree';
|
||||
import {
|
||||
concatEncodedArrays,
|
||||
decodeNestedArray,
|
||||
encodeNestedArray,
|
||||
splitNestedArray
|
||||
} from './flatTree';
|
||||
|
||||
test('it correctly concats nested arrays', () => {
|
||||
const input_a = encodeNestedArray([1, 2, 3]);
|
||||
@@ -82,3 +87,80 @@ test('it correctly handles arrays with mixed data types', () => {
|
||||
const decoded = decodeNestedArray(encodeNestedArray(input));
|
||||
expect(decoded).toEqual(input);
|
||||
});
|
||||
|
||||
// Test splitNestedArray function
|
||||
test('it splits nested array into segments based on structure', () => {
|
||||
const input = [[1, 2], [3, 4]];
|
||||
const encoded = new Int32Array(encodeNestedArray(input));
|
||||
const split = splitNestedArray(encoded);
|
||||
|
||||
// Based on the actual behavior, splitNestedArray returns segments
|
||||
// but the specific behavior needs to match the implementation
|
||||
expect(Array.isArray(split)).toBe(true);
|
||||
expect(split.length).toBe(2);
|
||||
expect(split[0][0]).toBe(1);
|
||||
expect(split[0][1]).toBe(2);
|
||||
expect(split[1][0]).toBe(3);
|
||||
expect(split[1][1]).toBe(4);
|
||||
});
|
||||
|
||||
// Test splitNestedArray function
|
||||
test('it splits nested array into segments based on structure 2', () => {
|
||||
// dprint-ignore
|
||||
const encoded = new Int32Array([
|
||||
0, 1,
|
||||
0, 19,
|
||||
0, 1,
|
||||
0, 0, 0, 1060487823,
|
||||
1067592955, 1079491492, -1086248132, 1056069822,
|
||||
-1078247113, 1086620820, 1073133800, 1047681214,
|
||||
-1068353940, 1094067306, 1078792112, 0,
|
||||
1, 1,
|
||||
0, 19,
|
||||
0, 1,
|
||||
0, 0, 0, 1060487823,
|
||||
-1089446963, 1080524584, 1041006274, 1056069822,
|
||||
-1092176382, 1087031528, -1088851934, 1047681214,
|
||||
1081482392, 1094426140, -1107842261, 0,
|
||||
1, 1,
|
||||
1, 1
|
||||
]);
|
||||
|
||||
// Should be split into two seperate arrays
|
||||
const split = splitNestedArray(encoded);
|
||||
|
||||
// Based on the actual behavior, splitNestedArray returns segments
|
||||
// but the specific behavior needs to match the implementation
|
||||
expect(Array.isArray(split)).toBe(true);
|
||||
expect(split.length).toBe(2);
|
||||
expect(split[0][0]).toBe(0);
|
||||
expect(split[0][1]).toBe(1);
|
||||
expect(split[1][0]).toBe(0);
|
||||
expect(split[1][1]).toBe(1);
|
||||
});
|
||||
|
||||
// Test splitNestedArray function
|
||||
test('it splits nested array into segments based on structure 2', () => {
|
||||
// dprint-ignore
|
||||
const encoded = new Int32Array( [
|
||||
0, 1,
|
||||
0, 27,
|
||||
0, 1,
|
||||
0, 0, 0, 1065353216,
|
||||
0, 1067757391, 0, 1061997773,
|
||||
0, 1076145999, 0, 1058642330,
|
||||
0, 1081542391, 0, 1053609164,
|
||||
0, 1084534607, 0, 1045220556,
|
||||
0, 1087232803, 0, 0,
|
||||
1, 1,
|
||||
1, 1
|
||||
]);
|
||||
|
||||
// Should be split into two seperate arrays
|
||||
const split = splitNestedArray(encoded);
|
||||
|
||||
// Based on the actual behavior, splitNestedArray returns segments
|
||||
// but the specific behavior needs to match the implementation
|
||||
expect(Array.isArray(split)).toBe(true);
|
||||
expect(split.length).toBe(1);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user