2020-07-13 21:26:50 -04:00
|
|
|
import unittest
|
2017-03-27 05:20:27 -04:00
|
|
|
|
|
|
|
|
2020-07-13 21:26:50 -04:00
|
|
|
class TestPowerSet(unittest.TestCase):
|
2017-03-27 05:20:27 -04:00
|
|
|
|
|
|
|
def test_power_set(self):
|
|
|
|
input_set = ''
|
|
|
|
expected = ['']
|
|
|
|
self.run_test(input_set, expected)
|
|
|
|
input_set = 'a'
|
|
|
|
expected = ['a', '']
|
|
|
|
self.run_test(input_set, expected)
|
|
|
|
input_set = 'ab'
|
|
|
|
expected = ['a', 'ab', 'b', '']
|
|
|
|
self.run_test(input_set, expected)
|
|
|
|
input_set = 'abc'
|
|
|
|
expected = ['a', 'ab', 'abc', 'ac',
|
|
|
|
'b', 'bc', 'c', '']
|
|
|
|
self.run_test(input_set, expected)
|
|
|
|
input_set = 'aabc'
|
|
|
|
expected = ['a', 'aa', 'aab', 'aabc',
|
|
|
|
'aac', 'ab', 'abc', 'ac',
|
|
|
|
'b', 'bc', 'c', '']
|
|
|
|
self.run_test(input_set, expected)
|
|
|
|
print('Success: test_power_set')
|
|
|
|
|
|
|
|
def run_test(self, input_set, expected):
|
|
|
|
combinatoric = Combinatoric()
|
|
|
|
result = combinatoric.find_power_set(input_set)
|
2020-07-13 21:26:50 -04:00
|
|
|
self.assertEqual(result, expected)
|
2017-03-27 05:20:27 -04:00
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
test = TestPowerSet()
|
|
|
|
test.test_power_set()
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2020-07-13 21:26:50 -04:00
|
|
|
main()
|