40 lines
1.1 KiB
Python
Executable File
40 lines
1.1 KiB
Python
Executable File
#!/usr/bin/python3
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
Zadanie 108
|
|
|
|
Napisz funkcję `leet_speak`, która podmienia w podanym napisie
|
|
niektóre litery na podobnie wyglądające cyfry: 'e' na '3', 'l' na '1',
|
|
'o' na '0', 't' na '7'. Np. `leet('leet')` powinno zwrócić '1337'.
|
|
|
|
NAME: leet_speak
|
|
PARAMS: string
|
|
RETURN: string
|
|
POINTS: 1
|
|
"""
|
|
|
|
import unittest
|
|
from Task108 import leet_speak
|
|
|
|
class Task108Test(unittest.TestCase):
|
|
"""Testy do zadania 108."""
|
|
|
|
def test_special_cases(self):
|
|
"""Przypadki szczególne."""
|
|
self.assertEqual(leet_speak(''), '')
|
|
self.assertEqual(leet_speak('x'), 'x')
|
|
self.assertEqual(leet_speak('o'), '0')
|
|
self.assertEqual(leet_speak('banan'), 'banan')
|
|
self.assertEqual(leet_speak('1337'), '1337')
|
|
self.assertEqual(leet_speak('admin1'), 'admin1')
|
|
|
|
def test_standard_cases(self):
|
|
"""Standardowe przypadki."""
|
|
self.assertEqual(leet_speak('leet'), '1337')
|
|
self.assertEqual(leet_speak('mouse'), 'm0us3')
|
|
self.assertEqual(leet_speak('do not want'), 'd0 n07 wan7')
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|