-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCombination_test.py
41 lines (31 loc) · 1.05 KB
/
Combination_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import pytest
from pcg import combinations
@pytest.fixture
def nums():
return [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
@pytest.fixture
def combination():
return []
def test_simpleCombination(resetSeed, nums, combination):
expected = [1, 2, 3, 6]
combinations.generateCombination(
nums,
lambda index, included: combination.append(nums[index]) if included else None,
)
assert expected == combination
def test_combinationWith7Elements(resetSeed, nums, combination):
expected = [1, 2, 3, 4, 5, 6, 8]
combinations.generateCombinationWithMinimumElements(
nums,
7,
lambda index, included: combination.append(nums[index]) if included else None,
)
assert expected == combination
def test_combinationWith1And3And10Active(resetSeed, nums, combination):
expected = [1, 2, 3, 6, 10]
combinations.generateCombinationWithIncludedElements(
nums,
[1, 3, 10],
lambda index, included: combination.append(nums[index]) if included else None,
)
assert expected == combination