Saturday 25 November 2017

TrafficControl: Time Needed for Reading Network File and a Real Bug

In a previous blog post, I mentioned that it took more time to load a network file. The reason for the delay was that I compiled the program in debug mode. After compiling in debug mode, reading a large network file took some 20-25 seconds. The same operation takes 5 seconds on a release build. However, I'll need a test to benchmark such operations.

A real bug was found when defining an unit test case for the train load passenger method.

For a train with a capacity of 100, the test adds four passengers and later 100 passengers. The expected result is that four passengers will be denied.
The test tries to load more passengers than the train has capacity for. The expected verdict is that the train will be full and that the load method will return the number of passengers that were denied entry to the train.

The load function didn't consider the train capacity or the number of present passengers. This was fixed:

After the fix, the new testcase is passing.

The passenger handling is stubbed. In the future, the program needs to make the passengers plan their journey.

No comments:

Post a Comment