コード例 #1
0
    def test_init(self):
        r = Road(3, 20, None)
        self.assertEqual(3, r.getLanesCount())
        self.assertEqual(20, r.getLength())
        self.assertEqual(r.carCount(), 0)

        # road is empty, so we should be able to add a car
        self.assertTrue(r.addCar())
        self.assertEqual(1, r.carCount())
コード例 #2
0
    def test_init(self):
        r = Road(3, 20, None)
        self.assertEqual(3, r.getLanesCount())
        self.assertEqual(20, r.getLength())
        self.assertEqual(r.carCount(), 0)

        # road is empty, so we should be able to add a car
        self.assertTrue(r.addCar())
        self.assertEqual(1, r.carCount())
コード例 #3
0
 def test_placeObject(self):
     r = Road(3, 40, None)
     car1, car2 = Car(r, (20, 0)), Car(r, (30, 0))
     self.assertTrue(r.placeObjects([car1, car2]))
     self.assertEqual(2, r.carCount())
     self.assertEqual(9, r.distanceToNextThing(car1.pos))
     self.assertTrue(r.distanceToNextThing(car2.pos) >= r.getLength())
     car3 = Car(r, (21, 0))
     self.assertTrue(r.placeObject(car3))
     self.assertEqual(3, r.carCount())
     self.assertEqual(0, r.distanceToNextThing(car1.pos))
     self.assertEqual(8, r.distanceToNextThing(car3.pos))
コード例 #4
0
 def test_placeObject(self):
     r = Road(3, 40, None)
     car1, car2 = Car(r, (20, 0)), Car(r, (30, 0))
     self.assertTrue(r.placeObjects([car1, car2]))
     self.assertEqual(2, r.carCount())
     self.assertEqual(9, r.distanceToNextThing(car1.pos))
     self.assertTrue(r.distanceToNextThing(car2.pos) >= r.getLength())
     car3 = Car(r, (21, 0))
     self.assertTrue( r.placeObject(car3) )
     self.assertEqual(3, r.carCount())
     self.assertEqual(0, r.distanceToNextThing(car1.pos))
     self.assertEqual(8, r.distanceToNextThing(car3.pos))