Skip to content

Commit

Permalink
Update test_binary_to_string.py
Browse files Browse the repository at this point in the history
  • Loading branch information
ikostan committed Dec 17, 2024
1 parent 4a5bfbc commit 62ae6a5
Showing 1 changed file with 38 additions and 35 deletions.
73 changes: 38 additions & 35 deletions kyu_6/binary_to_text_ascii_conversion/test_binary_to_string.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,35 +33,8 @@
class SequenceTestCase(unittest.TestCase):
"""Testing binary_to_string function."""

@parameterized.expand([
('0100100001100101011011000110110001101111', 'Hello'),
('00110001001100000011000100110001', '1011'),
('010100110111000001100001011100100110101101'
'110011001000000110011001101100011001010111'
'011100101110001011100010000001100101011011'
'010110111101110100011010010110111101101110'
'011100110010000001110010011000010110111000'
'100000011010000110100101100111011010000010'
'0001', 'Sparks flew.. emotions ran high!'),
('001000010100000000100011001001000010010101'
'011110001001100010101000101000001010010101'
'000101010111010001010111001001110100011110'
'010101010101001001010011110100110001100100'
'011001100110011101100010011000100110100001'
'101110011011010100100101001011010000100100'
'101001001011010010000100100101010101010011'
'110010100000111111001111100011111100111100'
'011111100111111001111110011111100111111000'
'101001001010000010101000100110001001010101'
'111000111001001110000011011100110001001100'
'110010111100101101001011110010101000101101'
'0010101000101111',
'!@#$%^&*()QWErtyUIOLdfgbbhnmIKBJKHIUO'
'(?>?<~~~~~)(*&%^98713/-/*-*/'),
('011001100111011101101111001100010110001101'
'101110001101100110011001101010011100010110'
'010101110001', 'fwo1cn6fjqeq')])
def test_binary_to_string(self, binary, expected):
@parameterized.expand([])
def test_binary_to_string(self):
"""
Testing binary_to_string function with various test data.
Expand All @@ -78,14 +51,44 @@ def test_binary_to_string(self, binary, expected):
"<p>Test a function that takes in a binary string and returns "
"the equivalent decoded text (the text is ASCII encoded).</p>")
# pylint: enable-msg=R0801
actual_result = binary_to_string(binary)
with allure.step(f"Enter a binary ({binary}) and verify the "
f"expected output ({expected}) vs "
f"actual result ({actual_result})"):
test_data: tuple = (
('0100100001100101011011000110110001101111', 'Hello'),
('00110001001100000011000100110001', '1011'),
('010100110111000001100001011100100110101101'
'110011001000000110011001101100011001010111'
'011100101110001011100010000001100101011011'
'010110111101110100011010010110111101101110'
'011100110010000001110010011000010110111000'
'100000011010000110100101100111011010000010'
'0001', 'Sparks flew.. emotions ran high!'),
('001000010100000000100011001001000010010101'
'011110001001100010101000101000001010010101'
'000101010111010001010111001001110100011110'
'010101010101001001010011110100110001100100'
'011001100110011101100010011000100110100001'
'101110011011010100100101001011010000100100'
'101001001011010010000100100101010101010011'
'110010100000111111001111100011111100111100'
'011111100111111001111110011111100111111000'
'101001001010000010101000100110001001010101'
'111000111001001110000011011100110001001100'
'110010111100101101001011110010101000101101'
'0010101000101111',
'!@#$%^&*()QWErtyUIOLdfgbbhnmIKBJKHIUO'
'(?>?<~~~~~)(*&%^98713/-/*-*/'),
('011001100111011101101111001100010110001101'
'101110001101100110011001101010011100010110'
'010101110001', 'fwo1cn6fjqeq'))

print_log(binary=binary,
for binary, expected in test_data:
actual_result = binary_to_string(binary)
with allure.step(f"Enter a binary ({binary}) and verify the "
f"expected output ({expected}) vs "
f"actual result ({actual_result})"):

print_log(binary=binary,
expected=expected,
result=actual_result)

self.assertEqual(expected,
self.assertEqual(expected,
actual_result)

0 comments on commit 62ae6a5

Please sign in to comment.