One such test case is stationTest.invalidFloatCoordinatesAtCreation.
The test case creates a station at 105°N, 13°E, and also another station at 55°N, 213°E. When testing, the result is:
The code is checking only the latitude for correct values. It also doesn't set the coordinate to 0, if the values are bad.
The new code that is passing is:
I also added a check in station::getLatitude and getLongitude, so that it returns 0 if hasCoordinates is false.
I'll investigate if I can define a more generic algorithm for validating coordinates, since that will be usefulwhen validating tracks in the future.
![]() |
The first coordinate is too big, but is parsed to the station anyways. In the second case, the coordinates are wrongly accepted. |
The new code that is passing is:
I also added a check in station::getLatitude and getLongitude, so that it returns 0 if hasCoordinates is false.
I'll investigate if I can define a more generic algorithm for validating coordinates, since that will be usefulwhen validating tracks in the future.
![]() |
The location of 0 degrees N, 0 degrees E. It is tempting to let 0/0 indicate that there is no such station, but such assumptions can be dangerous. |
When defining the test case, a part of me wanted to skip the check for coordinatues. That feeling is a very good reason to out extra focus on that test.
No comments:
Post a Comment