generated from filipe1309/shubcogen-template
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathsolution.spec.ts
19 lines (18 loc) · 881 Bytes
/
solution.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import { describe, expect, test } from '@jest/globals';
import cases from './cases';
import {
solution0, // createSet O(1) time | O(1) space, find O(n) time | O(1) space, union O(n) time | O(1) space
solution1, // createSet O(1) time | O(1) space, find O(n) time | O(1) space, union O(n) time | O(1) space
solution2, // createSet O(1) time | O(1) space, find O(n) time | O(1) space, union O(logn) time | O(1) space
solution3, // createSet O(1) time | O(1) space, find O(α(n)) time | O(1) space, union O(α(n)) time | O(1) space
} from "./solutions";
// Test: make test t=union-find
describe('union-find', () => {
test.each(cases)('%# (%j)', ({ expected }) => {
const unionFind = new solution3();
expected.forEach(({ method, arguments: args, output }) => {
const result = unionFind[method](...args);
expect(result).toEqual(output);
});
});
});