Sha256: 20b65ac44ccc50935f89a802bf26372a59ca8616c876203cb733d4e80f45cf9e

Contents?: true

Size: 1.94 KB

Versions: 26

Compression:

Stored size: 1.94 KB

Contents

import unittest

from say import say


class SayTest(unittest.TestCase):

    def test_one(self):
        self.assertEqual("one", say(1))

    def test_fourteen(self):
        self.assertEqual("fourteen", say(14))

    def test_twenty(self):
        self.assertEqual("twenty", say(20))

    def test_twenty_two(self):
        self.assertEqual("twenty-two", say(22))

    def test_one_hundred(self):
        self.assertEqual("one hundred", say(100))

    def test_one_hundred_twenty(self):
        self.assertEqual("one hundred and twenty", say(120))

    def test_one_hundred_twenty_three(self):
        self.assertEqual("one hundred and twenty-three", say(123))

    def test_one_thousand(self):
        self.assertEqual("one thousand", say(1000))

    def test_one_thousand_two_hundred_thirty_four(self):
        self.assertEqual("one thousand two hundred and thirty-four",
                         say(1234))

    def test_one_million(self):
        self.assertEqual("one million", say(1e6))

    def test_one_million_two(self):
        self.assertEqual("one million and two", say(1000002))

    def test_1002345(self):
        self.assertEqual(
            "one million two thousand three hundred and forty-five",
            say(1002345))

    def test_one_billion(self):
        self.assertEqual("one billion", say(1e9))

    def test_number_to_large(self):
        with self.assertRaises(AttributeError):
            say(1e12)

    def test_number_negative(self):
        with self.assertRaises(AttributeError):
            say(-42)

    def test_zero(self):
        self.assertEqual("zero", say(0))

    def test_987654321123(self):
        self.assertEqual("nine hundred and eighty-seven billion " +
                         "six hundred and fifty-four million " +
                         "three hundred and twenty-one thousand " +
                         "one hundred and twenty-three",
                         say(987654321123))

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

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
trackler-2.0.3.0 tracks/python/exercises/say/say_test.py
trackler-2.0.2.0 tracks/python/exercises/say/say_test.py
trackler-2.0.1.2 tracks/python/exercises/say/say_test.py
trackler-2.0.1.1 tracks/python/exercises/say/say_test.py
trackler-2.0.1.0 tracks/python/exercises/say/say_test.py
trackler-2.0.0.10 tracks/python/exercises/say/say_test.py
trackler-2.0.0.9 tracks/python/exercises/say/say_test.py
trackler-2.0.0.8 tracks/python/exercises/say/say_test.py
trackler-2.0.0.7 tracks/python/exercises/say/say_test.py
trackler-2.0.0.6 tracks/python/exercises/say/say_test.py
trackler-2.0.0.5 tracks/python/exercises/say/say_test.py
trackler-2.0.0.4 tracks/python/exercises/say/say_test.py
trackler-2.0.0.3 tracks/python/exercises/say/say_test.py
trackler-2.0.0.2 tracks/python/exercises/say/say_test.py
trackler-2.0.0.1 tracks/python/exercises/say/say_test.py
trackler-2.0.0.0 tracks/python/exercises/say/say_test.py
trackler-1.0.4.1 tracks/python/exercises/say/say_test.py
trackler-1.0.4.0 tracks/python/exercises/say/say_test.py
trackler-1.0.3.0 tracks/python/exercises/say/say_test.py
trackler-1.0.2.1 tracks/python/exercises/say/say_test.py