Exemplo n.º 1
0
    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)
Exemplo n.º 2
0
    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)
Exemplo n.º 3
0
    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)
Exemplo n.º 4
0
    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)
Exemplo n.º 5
0
    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)
Exemplo n.º 6
0
    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)
Exemplo n.º 7
0
    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)
Exemplo n.º 8
0
    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)