    @Test
    public final void testOutFlow() {

        RoadSegment.resetNextId();
        Vehicle.resetNextId();

        final int laneCount = 1;
        final RoadSegment r0 = new RoadSegment(1000.0, laneCount);
        final RoadSegment r1 = new RoadSegment(5000.0, laneCount);
        // join r0 and r1 so vehicles move from r0 to r1
        Link.addJoin(r0, r1);

        final Vehicle v0 = newVehicle(999.0, 40.0, Lanes.LANE1);
        r0.addVehicle(v0);
        final double dt = 0.25;
        final double simulationTime = 0.0;
        final long iterationCount = 0;
        r0.updateVehiclePositionsAndSpeeds(dt, simulationTime, iterationCount);
        assertEquals(1009.0, v0.getRearPosition(), delta);
        r0.outFlow(dt, simulationTime, iterationCount);
        assertEquals(0, r0.getVehicleCount());
        assertEquals(1, r1.getVehicleCount());
        final Vehicle v = r1.getVehicle(Lanes.LANE1, 0);
        assertEquals(9.0, v.getRearPosition(), delta);
    }