Package test_suite :: Package unit_tests :: Package _lib :: Module test_mathematics
[hide private]
[frames] | no frames]

Source Code for Module test_suite.unit_tests._lib.test_mathematics

 1  ############################################################################### 
 2  #                                                                             # 
 3  # Copyright (C) 2013 Edward d'Auvergne                                        # 
 4  #                                                                             # 
 5  # This file is part of the program relax (http://www.nmr-relax.com).          # 
 6  #                                                                             # 
 7  # This program is free software: you can redistribute it and/or modify        # 
 8  # it under the terms of the GNU General Public License as published by        # 
 9  # the Free Software Foundation, either version 3 of the License, or           # 
10  # (at your option) any later version.                                         # 
11  #                                                                             # 
12  # This program is distributed in the hope that it will be useful,             # 
13  # but WITHOUT ANY WARRANTY; without even the implied warranty of              # 
14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               # 
15  # GNU General Public License for more details.                                # 
16  #                                                                             # 
17  # You should have received a copy of the GNU General Public License           # 
18  # along with this program.  If not, see <http://www.gnu.org/licenses/>.       # 
19  #                                                                             # 
20  ############################################################################### 
21   
22  # Module docstring. 
23  """Unit tests of the lib.mathematics module.""" 
24   
25  # Python module imports. 
26  from unittest import TestCase 
27   
28  # relax module imports. 
29  from lib.mathematics import order_of_magnitude, round_to_next_order 
30   
31   
32 -class Test_mathematics(TestCase):
33 """Unit tests for the lib.mathematics relax module.""" 34
36 """0th test of the lib.mathematics.order_of_magnitude function.""" 37 38 self.assertEqual(order_of_magnitude(0.123), 0.0)
39 40
42 """1st test of the lib.mathematics.order_of_magnitude function.""" 43 44 self.assertEqual(order_of_magnitude(1.1), 1.0)
45 46
48 """2nd test of the lib.mathematics.order_of_magnitude function.""" 49 50 self.assertEqual(order_of_magnitude(12), 2.0)
51 52
54 """3rd test of the lib.mathematics.order_of_magnitude function.""" 55 56 self.assertEqual(order_of_magnitude(123), 3.0)
57 58
60 """4th test of the lib.mathematics.order_of_magnitude function.""" 61 62 self.assertEqual(order_of_magnitude(1234), 4.0)
63 64
66 """0th test of the lib.mathematics.round_to_next_order function.""" 67 68 self.assertEqual(round_to_next_order(0.123), 1.0)
69 70
72 """1st test of the lib.mathematics.round_to_next_order function.""" 73 74 self.assertEqual(round_to_next_order(1.1), 10.0)
75 76
78 """2nd test of the lib.mathematics.round_to_next_order function.""" 79 80 self.assertEqual(round_to_next_order(12), 100.0)
81 82
84 """3rd test of the lib.mathematics.round_to_next_order function.""" 85 86 self.assertEqual(round_to_next_order(123), 1000.0)
87 88
90 """4th test of the lib.mathematics.round_to_next_order function.""" 91 92 self.assertEqual(round_to_next_order(1234), 10000.0)
93