Sha256: e4c99c674e110508b4cb913279a5766eafce82b1af7a1a07f0290f13595a3ec9

Contents?: true

Size: 1.52 KB

Versions: 127

Compression:

Stored size: 1.52 KB

Contents

"""
You can make the following assumptions about the inputs to the
'sum_of_multiples' function:
    * All input numbers are non-negative 'int's, i.e. natural numbers including
      zero.
    * A list of factors must be given, and its elements are unique and sorted in
      ascending order.
"""

import unittest

from sum_of_multiples import sum_of_multiples


class SumOfMultiplesTest(unittest.TestCase):
    def test_sum_to_1(self):
        self.assertEqual(0, sum_of_multiples(1, [3, 5]))

    def test_sum_to_3(self):
        self.assertEqual(3, sum_of_multiples(4, [3, 5]))

    def test_sum_to_10(self):
        self.assertEqual(23, sum_of_multiples(10, [3, 5]))

    def test_sum_to_100(self):
        self.assertEqual(2318, sum_of_multiples(100, [3, 5]))

    def test_sum_to_1000(self):
        self.assertEqual(233168, sum_of_multiples(1000, [3, 5]))

    def test_configurable_7_13_17_to_20(self):
        self.assertEqual(51, sum_of_multiples(20, [7, 13, 17]))

    def test_configurable_4_6_to_15(self):
        self.assertEqual(30, sum_of_multiples(15, [4, 6]))

    def test_configurable_5_6_8_to_150(self):
        self.assertEqual(4419, sum_of_multiples(150, [5, 6, 8]))

    def test_configurable_43_47_to_10000(self):
        self.assertEqual(2203160, sum_of_multiples(10000, [43, 47]))

    def test_configurable_0_to_10(self):
        self.assertEqual(0, sum_of_multiples(10, [0]))

    def test_configurable_0_1_to_10(self):
        self.assertEqual(45, sum_of_multiples(10, [0, 1]))


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

Version data entries

127 entries across 127 versions & 1 rubygems

Version Path
trackler-2.0.8.27 tracks/python/exercises/sum-of-multiples/sum_of_multiples_test.py
trackler-2.0.8.26 tracks/python/exercises/sum-of-multiples/sum_of_multiples_test.py
trackler-2.0.8.24 tracks/python/exercises/sum-of-multiples/sum_of_multiples_test.py
trackler-2.0.8.23 tracks/python/exercises/sum-of-multiples/sum_of_multiples_test.py
trackler-2.0.8.22 tracks/python/exercises/sum-of-multiples/sum_of_multiples_test.py
trackler-2.0.8.21 tracks/python/exercises/sum-of-multiples/sum_of_multiples_test.py
trackler-2.0.8.20 tracks/python/exercises/sum-of-multiples/sum_of_multiples_test.py
trackler-2.0.8.19 tracks/python/exercises/sum-of-multiples/sum_of_multiples_test.py
trackler-2.0.8.18 tracks/python/exercises/sum-of-multiples/sum_of_multiples_test.py
trackler-2.0.8.17 tracks/python/exercises/sum-of-multiples/sum_of_multiples_test.py
trackler-2.0.8.16 tracks/python/exercises/sum-of-multiples/sum_of_multiples_test.py
trackler-2.0.8.15 tracks/python/exercises/sum-of-multiples/sum_of_multiples_test.py
trackler-2.0.8.14 tracks/python/exercises/sum-of-multiples/sum_of_multiples_test.py
trackler-2.0.8.13 tracks/python/exercises/sum-of-multiples/sum_of_multiples_test.py
trackler-2.0.8.12 tracks/python/exercises/sum-of-multiples/sum_of_multiples_test.py
trackler-2.0.8.11 tracks/python/exercises/sum-of-multiples/sum_of_multiples_test.py
trackler-2.0.8.10 tracks/python/exercises/sum-of-multiples/sum_of_multiples_test.py
trackler-2.0.8.9 tracks/python/exercises/sum-of-multiples/sum_of_multiples_test.py
trackler-2.0.8.8 tracks/python/exercises/sum-of-multiples/sum_of_multiples_test.py
trackler-2.0.8.7 tracks/python/exercises/sum-of-multiples/sum_of_multiples_test.py