Completed
Branch master (df357f)
by Chris
12:05
created

tests.test_util.RationalTestCases.test_rational_helpers()   A

Complexity

Conditions 1

Size

Total Lines 32
Code Lines 21

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 21
nop 1
dl 0
loc 32
rs 9.376
c 0
b 0
f 0
1
# -*- coding: utf-8 -*-
2
3
# Copyright 2014-2018 by Christopher C. Little.
4
# This file is part of Abydos.
5
#
6
# Abydos is free software: you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation, either version 3 of the License, or
9
# (at your option) any later version.
10
#
11
# Abydos is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
# GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License
17
# along with Abydos. If not, see <http://www.gnu.org/licenses/>.
18
19
"""abydos.tests.test_util.
20
21
This module contains unit tests for abydos.util
22
"""
23
24
import unittest
25
26
from abydos.util import prod
27
28
from six.moves import range
0 ignored issues
show
introduced by
third party import "from six.moves import range" should be placed before "from abydos.util import prod"
Loading history...
29
30
31
class ProdTestCases(unittest.TestCase):
32
    """Test cases for abydos.util.prod."""
33
34
    def test_prod(self):
35
        """Test abydos.util.prod."""
36
        self.assertEqual(prod([]), 1)
37
        self.assertEqual(prod(()), 1)
38
        self.assertEqual(prod({}), 1)
39
40
        self.assertEqual(prod([1, 1, 1, 1, 1]), 1)
41
        self.assertEqual(prod((1, 1, 1, 1, 1)), 1)
42
        self.assertEqual(prod({1, 1, 1, 1, 1}), 1)
43
44
        self.assertEqual(prod([2, 2, 2, 2, 2]), 32)
45
        self.assertEqual(prod((2, 2, 2, 2, 2)), 32)
46
        self.assertEqual(prod({2, 2, 2, 2, 2}), 2)
47
48
        self.assertEqual(prod([1, 2, 3, 4, 5]), 120)
49
        self.assertEqual(prod((1, 2, 3, 4, 5)), 120)
50
        self.assertEqual(prod({1, 2, 3, 4, 5}), 120)
51
        self.assertEqual(prod(range(1, 6)), 120)
52
        self.assertEqual(prod(list(range(1, 6))), 120)
53
        self.assertEqual(prod(tuple(range(1, 6))), 120)
54
        self.assertEqual(prod(set(range(1, 6))), 120)
55
56
        self.assertEqual(prod(range(6)), 0)
57
        self.assertEqual(prod(list(range(6))), 0)
58
        self.assertEqual(prod(tuple(range(6))), 0)
59
        self.assertEqual(prod(set(range(6))), 0)
60
61
62
if __name__ == '__main__':
63
    unittest.main()
64