generated from filipe1309/shubcogen-template
-
Notifications
You must be signed in to change notification settings - Fork 6
/
solution.spec.ts
20 lines (19 loc) · 852 Bytes
/
solution.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import { describe, expect, test } from '@jest/globals';
import cases from './cases';
import { LinkedList } from 'common/LinkedList';
import {
solution0, // O(n * m) time | O(1) space
solution1, // O(n + m) time | O(1) space
solution2, // O(n + m) time | O(n) space
solution3, // O(n + m) time | O(1) space
} from "./solutions";
// Test: make test t=merging-linked-lists
describe('merging-linked-lists', () => {
test.each(cases)('%# (%j)', ({ input, expected }) => {
let linkedListOne = LinkedList.fromFlatArray(input.linkedListOne.nodes);
let linkedListTwo = LinkedList.fromFlatArray(input.linkedListTwo.nodes);
const result = solution3(linkedListOne, linkedListTwo);
let resultArray = result ? LinkedList.toFlatArray(result as LinkedList) : null;
expect(resultArray).toEqual(expected ? expected.nodes : null);
});
});