xen-dev-utils
Version:
Utility functions used by the Scale Workshop ecosystem
29 lines • 1.62 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const vitest_1 = require("vitest");
const combinations_1 = require("../combinations");
(0, vitest_1.describe)('K-combinations generator', () => {
(0, vitest_1.it)('produces all subsets of size 3 of the set {a, b, c, d}', () => {
const result = (0, combinations_1.kCombinations)(['a', 'b', 'c', 'd'], 3);
(0, vitest_1.expect)(result.map(subset => subset.join('')).join(',')).toBe('abc,abd,acd,bcd');
});
});
(0, vitest_1.describe)('Combinations generator', () => {
(0, vitest_1.it)('produces all subsets of the set {a, b, c}', () => {
const result = (0, combinations_1.combinations)(['a', 'b', 'c']);
(0, vitest_1.expect)(result.map(subset => subset.join('')).join(',')).toBe('a,b,c,ab,ac,bc,abc');
});
});
(0, vitest_1.describe)('K-combinations iterative generator', () => {
(0, vitest_1.it)('produces all subsets of size 2 of the set {a, b, c, d}', () => {
const result = [...(0, combinations_1.iterKCombinations)(['a', 'b', 'c', 'd'], 2)];
(0, vitest_1.expect)(result.map(subset => subset.join('')).join(',')).toBe('ab,ac,ad,bc,bd,cd');
});
});
(0, vitest_1.describe)('Combinations iterative generator', () => {
(0, vitest_1.it)('produces all subsets of the set {a, b, c, d}', () => {
const result = [...(0, combinations_1.iterCombinations)(['a', 'b', 'c', 'd'])];
(0, vitest_1.expect)(result.map(subset => subset.join('')).join(',')).toBe('a,b,c,d,ab,ac,ad,bc,bd,cd,abc,abd,acd,bcd,abcd');
});
});
//# sourceMappingURL=combinations.spec.js.map