Ejemplo n.º 1
0
 def test_powerset(self):
     powerset = new_powerset([1, 2, 3])
     assert len(powerset) == 2**3
     assert powerset == [[], [1], [2], [1, 2], [3], [1, 3], [2, 3],
                         [1, 2, 3]]
Ejemplo n.º 2
0
 def test_large_powerset(self):
     s = [x for x in range(1 << 4)]
     powerset = new_powerset(s)
     assert len(powerset) == 1 << len(s)
Ejemplo n.º 3
0
 def test_chars_powerset(self):
     powerset = new_powerset(list("abc"))
     expected = ['', 'a', 'b', 'ab', 'c', 'ac', 'bc', 'abc']
     assert len(powerset) == 2**3
     assert [''.join(x) for x in powerset] == expected
Ejemplo n.º 4
0
 def test_empty_powerset(self):
     powerset = new_powerset([])
     assert len(powerset) == 2**0
     assert powerset == [[]]
Ejemplo n.º 5
0
 def test_single_element_powerset(self):
     powerset = new_powerset([1])
     assert len(powerset) == 2**1
     assert powerset == [[], [1]]
Ejemplo n.º 6
0
 def test_two_elements_powerset(self):
     powerset = new_powerset([1, 2])
     assert len(powerset) == 2**2
     assert powerset == [[], [1], [2], [1, 2]]