Commit e4936932af2caa344ab2c5526d2a317a1aaf9c95
1 parent
eb988c7e
Add time operator unit tests
Showing
1 changed file
with
30 additions
and
0 deletions
test/test_GObservation.py
| ... | ... | @@ -50,6 +50,7 @@ class Test(GPythonTestSuite): |
| 50 | 50 | |
| 51 | 51 | # Append tests |
| 52 | 52 | self.append(self.test_energy, "Test GEnergy class") |
| 53 | + self.append(self.test_time, "Test GTime class") | |
| 53 | 54 | |
| 54 | 55 | # Return |
| 55 | 56 | return |
| ... | ... | @@ -89,3 +90,32 @@ class Test(GPythonTestSuite): |
| 89 | 90 | |
| 90 | 91 | # Return |
| 91 | 92 | return |
| 93 | + | |
| 94 | + | |
| 95 | + # Test GTime class | |
| 96 | + def test_time(self): | |
| 97 | + """ | |
| 98 | + Test GTime class. | |
| 99 | + """ | |
| 100 | + # Setup times | |
| 101 | + time = GTime(3.0) | |
| 102 | + time_b = time.copy() | |
| 103 | + | |
| 104 | + # Binary addition operator | |
| 105 | + time = time + time_b | |
| 106 | + self.test_value(time.secs(), 6.0); | |
| 107 | + | |
| 108 | + # Binary subtraction operator | |
| 109 | + time = time - time_b | |
| 110 | + self.test_value(time.secs(), 3.0); | |
| 111 | + | |
| 112 | + # Scalar multiplication operator | |
| 113 | + time = time * 2.0 | |
| 114 | + self.test_value(time.secs(), 6.0); | |
| 115 | + | |
| 116 | + # Scalar division operator | |
| 117 | + time = time / 2.0 | |
| 118 | + self.test_value(time.secs(), 3.0); | |
| 119 | + | |
| 120 | + # Return | |
| 121 | + return | ... | ... |