add test
This commit is contained in:
@@ -60,6 +60,33 @@ def rearrange_channel_mux_table(channel_table: List[bool]) -> Optional[List[int]
|
||||
return channel_mux
|
||||
|
||||
|
||||
def rearrange_channel_count(channel_table: List[int]) -> List[int]:
|
||||
ret = [0 for _ in range(REC_CHANNEL_COUNT)]
|
||||
|
||||
i = len(channel_table) - 1
|
||||
|
||||
if i < 0:
|
||||
return ret
|
||||
|
||||
c = channel_table[i]
|
||||
|
||||
if i == 0:
|
||||
ret[c] += 1
|
||||
return ret
|
||||
|
||||
while c >= 0:
|
||||
ret[channel_table[i]] += 1
|
||||
|
||||
c -= 1
|
||||
|
||||
if i == 0:
|
||||
i = len(channel_table) - 1
|
||||
else:
|
||||
i -= 1
|
||||
|
||||
return ret
|
||||
|
||||
|
||||
class UniRearrangeMuxChannelTest(unittest.TestCase):
|
||||
def test_empty_channel(self):
|
||||
self.assertIsNone(rearrange_channel_mux_table(to_channel_table()))
|
||||
@@ -100,5 +127,20 @@ class UniRearrangeMuxChannelTest(unittest.TestCase):
|
||||
rearrange_channel_mux_table(to_channel_table(0, 1, 2, 3, 4, 5)))
|
||||
|
||||
|
||||
class UniRearrangeChannelCount(unittest.TestCase):
|
||||
def test_empty_channel(self):
|
||||
self.assertEqual([0 for _ in range(REC_CHANNEL_COUNT)], rearrange_channel_count([]))
|
||||
|
||||
def test_single_channel(self):
|
||||
self.assertEqual([0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
rearrange_channel_count([2]))
|
||||
self.assertEqual([0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
rearrange_channel_count([4]))
|
||||
|
||||
def test_two_channel(self):
|
||||
self.assertEqual([0, 0, 2, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
rearrange_channel_count([2, 4]))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user