Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import unittest
- from solution import (nums_to_text, text_to_nums, nums_to_angle,
- angles_to_nums, is_phone_tastic)
- class TestNumsToText(unittest.TestCase):
- """Test the nums_to_text function."""
- def test_given_example(self):
- """The test given from the example."""
- self.assertEqual(nums_to_text([4, 4, 3, 3, 5, 5, 5, -1, 5, 5, 5, 6, 6, 6]), "HELLO")
- def test_minus_one(self):
- """Testing with -1."""
- self.assertEqual(nums_to_text([2, 7, 7, 7, 7, 3, -1, 3, 3, 3]), 'ASDF')
- def test_multiple_times(self):
- """Test pressing the 3 and 4 letter keys numerous"""
- self.assertEqual(
- nums_to_text([5, 5, 5, 5, 5, 5, 5, 5, 5, 9, 9, 9, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7]), 'LZUP')
- def test_spaces(self):
- """Test pressing the 0 for the spaces"""
- self.assertEqual(nums_to_text([7, 7, 8, 9, 9, 9, 0, 5, 5, 3, 3, 0, 2, 2, 2, 5]), 'QTY KE CJ')
- def test_missing_numbers(self):
- """Test for numbers not on the keys"""
- self.assertEqual(nums_to_text([1, 1, 1, -10, 2, 2, 2, 3, 10, 0, 2, 2, -1, 2]), 'CD BA')
- class TestTextToNums(unittest.TestCase):
- """Test the text_to_nums function."""
- def test_given_example(self):
- """The test given from the example."""
- self.assertEqual(text_to_nums("PYTHON"), [7, 9, 9, 9, 8, 4, 4, 6, 6, 6, -1, 6, 6])
- def test_second_example(self):
- """Testing with the second example test."""
- self.assertEqual(text_to_nums("asl pls"), [2, 7, 7, 7, 7, 5, 5, 5, 0, 7, 5, 5, 5, 7, 7, 7, 7])
- def test_multiple_times(self):
- """Testing with repeating letters"""
- self.assertEqual(text_to_nums("pPp YyY aaa BBB"),
- [7, -1, 7, -1, 7, 0, 9, 9, 9, -1, 9, 9, 9, -1, 9, 9, 9, 0, 2, -1, 2, -1, 2, 0, 2, 2, -1, 2, 2,
- -1, 2, 2])
- def test_lower_upper(self):
- """Test with lower and upper letters"""
- self.assertEqual(text_to_nums("aBcDeF GhIgK"),
- [2, -1, 2, 2, -1, 2, 2, 2, 3, -1, 3, 3, -1, 3, 3, 3, 0, 4, -1, 4, 4, -1, 4, 4, 4, -1, 4, 5, 5])
- def test_spaces(self):
- """Test with multiple spaces"""
- self.assertEqual(text_to_nums('foo bar baz'),
- [3, 3, 3, 6, 6, 6, -1, 6, 6, 6, 0, -1, 0, -1, 0, -1, 0, 2, 2, -1, 2, 7, 7, 7, 0, -1, 0, -1, 0,
- -1, 0, 2, 2, -1, 2, 9, 9, 9, 9])
- if __name__ == '__main__':
- unittest.main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement