def testCanGetDistanceToPreviousCar(self): car = Car(radius=100, alpha=0) anotherCar = Car(radius=100, alpha=math.pi / 2) car.previous_car = anotherCar self.assertAlmostEqual(100 * math.sqrt(2), car.distance_to_previous_car)
def testAccelerateWhenDistanceToPreviousCarIsBig(self): car = Car(radius=100, alpha=0, speed=1, speed_limit=2) anotherCar = Car(radius=100, alpha=math.pi, speed=1) car.previous_car = anotherCar car.move() self.assertAlmostEqual(1.2, car.speed)
def testDecelerateWhenDistanceToPreviousCarIsSmall(self): car = Car(radius=100, alpha=0, speed=0.1) anotherCar = Car(radius=100, alpha=0.5, speed=0.1) car.previous_car = anotherCar car.move() self.assertAlmostEqual(0.08, car.speed)
def testStopWhenCrash(self): car = Car(radius=100, alpha=0, speed=1) anotherCar = Car(radius=100, alpha=0.01, speed=1) car.previous_car = anotherCar car.move() self.assertAlmostEqual(0, car.speed)