Skip to content

Commit 3afb159

Browse files
🔍 test: Complete test for larger input.
1 parent 354e2d8 commit 3afb159

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
"@aureooms/js-itertools": "^4.1.0"
8080
},
8181
"devDependencies": {
82+
"@aureooms/js-red-black-tree": "^2.0.7",
8283
"@babel/cli": "7.11.6",
8384
"@babel/core": "7.11.6",
8485
"@babel/preset-env": "7.11.5",
@@ -97,6 +98,7 @@
9798
"nyc": "15.1.0",
9899
"power-assert": "1.6.1",
99100
"regenerator-runtime": "0.13.7",
101+
"total-order": "^0.0.3",
100102
"xo": "0.33.1"
101103
},
102104
"files": [

test/src/7.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,26 @@
11
import test from 'ava';
22

3+
import totalOrder from 'total-order';
4+
import {RedBlackTree} from '@aureooms/js-red-black-tree';
5+
36
import {enumerate, _count, isPartition} from '../../src';
47

58
test('Check partitions of [7]', (t) => {
69
const set = [1, 2, 3, 4, 5, 6, 7];
710
const partitions = [...enumerate(set)];
11+
12+
// Check that number of partition is correct
813
t.is(partitions.length, _count(1, set.length));
14+
15+
// Check that each item is a partition
916
for (const partition of partitions) {
1017
t.true(isPartition(set, partition));
1118
}
19+
20+
// Check that partitions are pairwise distinct
21+
const seen = new RedBlackTree(totalOrder);
22+
for (const partition of partitions) {
23+
t.false(seen.has(partition));
24+
seen.add(partition);
25+
}
1226
});

yarn.lock

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
dependencies:
1010
"@aureooms/js-error" "^4.0.1"
1111

12+
"@aureooms/js-compare@^1.4.8":
13+
version "1.4.8"
14+
resolved "https://registry.yarnpkg.com/@aureooms/js-compare/-/js-compare-1.4.8.tgz#c6bff1091f4a2e211f449299572d9f195146fc59"
15+
integrity sha512-Z26PU6OmuhS7ZJsELTKImmipF7J+KCOyN70wBhhVIhmqUhXY6C3JpJHAev6wNBkC4ThlQt3zO6p/OmBFIq76Qg==
16+
1217
"@aureooms/js-error@^4.0.1":
1318
version "4.0.1"
1419
resolved "https://registry.yarnpkg.com/@aureooms/js-error/-/js-error-4.0.1.tgz#be2740b3f31a337e0828930c9b70d38113b4dd77"
@@ -22,6 +27,21 @@
2227
"@aureooms/js-collections-deque" "^4.0.1"
2328
"@aureooms/js-error" "^4.0.1"
2429

30+
"@aureooms/js-pairs@^0.0.0":
31+
version "0.0.0"
32+
resolved "https://registry.yarnpkg.com/@aureooms/js-pairs/-/js-pairs-0.0.0.tgz#a9d348c367511d4e70e166c73085ffc98c5fecf6"
33+
integrity sha512-zsyLmTpXZ2cQmVMCU1FnUIwiaaFEhZ9FiotgjVjsJLFhBoU+wIxykUyIDZXozRszQLnk5sa8gWIrnQ3azjQCUA==
34+
dependencies:
35+
"@aureooms/js-error" "^4.0.1"
36+
"@aureooms/js-itertools" "^4.1.0"
37+
38+
"@aureooms/js-red-black-tree@^2.0.7":
39+
version "2.0.7"
40+
resolved "https://registry.yarnpkg.com/@aureooms/js-red-black-tree/-/js-red-black-tree-2.0.7.tgz#653ee108e3a31b038288f9d425f858c9415dbffd"
41+
integrity sha1-ZT7hCOOjGwOCiPnUJfhYyUFdv/0=
42+
dependencies:
43+
chalk "^1.1.3"
44+
2545
2646
version "7.11.6"
2747
resolved "https://registry.yarnpkg.com/@babel/cli/-/cli-7.11.6.tgz#1fcbe61c2a6900c3539c06ee58901141f3558482"
@@ -7794,6 +7814,15 @@ to-regex@^3.0.1, to-regex@^3.0.2:
77947814
regex-not "^1.0.2"
77957815
safe-regex "^1.1.0"
77967816

7817+
total-order@^0.0.3:
7818+
version "0.0.3"
7819+
resolved "https://registry.yarnpkg.com/total-order/-/total-order-0.0.3.tgz#1befa517625a504058c039a01e9d403676ab0097"
7820+
integrity sha512-JQjxkk8D+2wR4g8iqqJKZNLCnOdbqJizv5bi2N2kPu5noWe0Q4GxV1xsCkY6BvgpXYnItVd3DHgFjP1tUqeLkw==
7821+
dependencies:
7822+
"@aureooms/js-compare" "^1.4.8"
7823+
"@aureooms/js-itertools" "^4.1.0"
7824+
"@aureooms/js-pairs" "^0.0.0"
7825+
77977826
tough-cookie@^2.2.0, tough-cookie@~2.5.0:
77987827
version "2.5.0"
77997828
resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.5.0.tgz#cd9fb2a0aa1d5a12b473bd9fb96fa3dcff65ade2"

0 commit comments

Comments
 (0)