コード例 #1
0
 def test_update(self):
     time = Time(3.0, 0.3247823)
     other_time = Time(6.0, 0.1231)
     time.update(other_time)
     self.assertEqual(time.quotient, 6.0)
     self.assertEqual(time.remainder, 0.1231)
     self.assertEqual(other_time.quotient, 6.0)
     self.assertEqual(other_time.remainder, 0.1231)
     self.assertIsNot(time, other_time)
コード例 #2
0
ファイル: test_unit.py プロジェクト: jellyfysh/JeLLyFysh
    def test_unit(self):
        test_position = [1]
        test_velocity = [2]
        test_time_stamp = Time(0.0, 0.4)
        unit = Unit(0,
                    test_position,
                    velocity=test_velocity,
                    time_stamp=test_time_stamp)
        self.assertEqual(unit.identifier, 0)
        self.assertEqual(unit.position, [1])
        self.assertIsNone(unit.charge)
        self.assertEqual(unit.velocity, [2])
        self.assertEqual(unit.time_stamp, Time(0.0, 0.4))

        # The position, velocity and time stamp was not copied
        test_position[0] += 1
        test_velocity[0] /= 2
        test_time_stamp.update(Time(1.0, 0.1))
        self.assertEqual(unit.position, [2])
        self.assertEqual(unit.velocity, [1])
        self.assertEqual(unit.time_stamp, Time(1.0, 0.1))