Snippets

Alexander Stoilov qkz6z4: Untitled snippet

Created by Alexander Stoilov
import unittest

from solution import calculate_final_vector


class TestCalculateFinalVector01(unittest.TestCase):

    test_cases = [
        ((0, 0), ['00C000', 'C0FFC0', 'C00000', 'FFFFFF', 'C0C000'], (-1, 1)),
        ((0, 0), ['00c000', 'C0fFc0', 'c00000', 'FfFfff', 'c0c000'], (-1, 1)),
        ((0, 0), ['00C000', '000000', 'C00000', 'FFFFFF'], (1, 0)),
        ((0, 0), ['00C000', 'FFFFFF', 'C00000', 'FFFFFF'], (0, 0)),
        ((0, 0), ['00C000', '00C000', '00C000', '00C000', '00C000'], (5, 0)),
        ((0, 0), ['FFFFFF', 'FFFFFF', 'FFFFFF', 'FFFFFF', 'FFFFFF'], (0, 0)),
        ((0, 0), ['00c000', 'c0c000'], (1, 1)),
        ((0, 0), [], (0, 0)),
    ]

    def test_all_own_cases(self):
        for [(x, y), colors_list, expected] in self.test_cases:
            output = calculate_final_vector((x, y), colors_list)
            assert output == expected, \
                f'(x,y) = {(x, y)}, ' + \
                f'colors_list = {colors_list}, ' + \
                f'output = {output}, ' + \
                f'expected = {expected}'


if __name__ == "__main__":
    unittest.main()

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.