Thursday, August 11, 2011

CQ Simulation: More Tests

I need to spend a longer session getting organized, again, on this project. Lately, I've been accomplishing a certain amount of coding, but I'm not sure where it's all headed.

And the way that I generally organize things is by building tests.

I started out with the operational test I did earlier. This test is designed to run the simulation as it is intended to run.


# create simulation with 6 seats at 30 minutes per seat.

$testSimulation = new Simulation(6, 30)


I added 12 users and then did the following test:


$testSimulation.queueSize()

$testSimulation.tick()

$testSimulation.queueSize()


One tick should only advance the simulation by one tick and none of my users joined the queue at time 0 or 1, so one tick should have no effect on the (user) queue size.

But it did. The results were 12 then 6.

Which means that half the users got to sit down.

Which means the code is broken.

WAIT: I don't want to jump to conclusions. If the users are going away by sitting down, instead of by having the abandon mechanism broken, then I can change the number of seats to 5 and get first 12 then 7.

That prediction was correct, so I'm betting the problem is in the tick method of the simulation class.


OK, reviewing the code, the way I wrote it, it relies on the list being ordered by time when the user queues up and it doesn't check whether a user has queued up.

I'll start fixes next time.

No comments:

Post a Comment