Creating a bitarray

This commit is contained in:
mjalalzai 2023-06-11 13:52:08 -07:00
parent 6518350ff4
commit fe9d1ecbbe

View File

@ -15,3 +15,38 @@ class TestCountOnBitarrayFields(unittest.TestCase):
self.assertEqual(result, expected_result)
class TestCreateCommitteeBitArray(unittest.TestCase):
class Vote:
def __init__(self, voter):
self.voter = voter
def test_createCommitteeBitArray_with_smaller_committee_size(self):
voters = [
self.Vote("Alice"),
self.Vote("Bob"),
self.Vote("Charlie")
]
committee_size = 2
try:
result = createCommitteeBitArray(voters, committee_size)
self.fail("AssertionError should have been raised.")
except AssertionError:
pass
def test_createCommitteeBitArray_with_larger_committee_size(self):
voters = [
self.Vote("Alice"),
self.Vote("Bob"),
self.Vote("Charlie"),
self.Vote("Dave"),
self.Vote("Eve")
]
committee_size = 6
result = createCommitteeBitArray(voters, committee_size)
expected_result = [True, True, True, True, True, False]
self.assertEqual(result, expected_result)