cjsolomon / Mulit-Modal

SRU Multi-Modal Project
0 stars 2 forks source link

Segment Error Checking #26

Closed ghost closed 10 years ago

ghost commented 10 years ago

Zach,

Can you replace the hard-coded error checking with error checking in the error checking FormatChecking. You may have to create a new method in Format checking that just takes a lower bound.

Please update error checking in the following methods: o Segment.setDistance() - needs to check that all doubles passed in are between two values o Segment.setEstimatedArrivalTime() - needs to check that integers passed in are between two values. In general the parameter passed in is between earliest and latest arrival time. o Segment.setEstimatedDepartureTime() - same as above o Segment.setEarliestArrival/DepartureTime() - need to make sure that it is not after the LatestArrival/Departure Time o Segment.setLatestArrival/DepartureTime() - need to make sure it is not before the EarilstArrival/DepartureTime() these tests currently fail in JUnit but will pass once error checking is correctly implemented

Let me know if you end up adding new methods to FormatChecker so that I can update the testing accordingly. Thanks

zgp1001 commented 10 years ago

Added the testing to segment.

2 new functions in format checker: checkLowerBound checkUpperBound

compares the first double passed to the second. First one requires that it be higher than the second while upperBound requires that it be less than.

ghost commented 10 years ago

Zach the JUnit stuff for Segment should be passing if the error checkin is correct. It is still not passing. Please look at the setter and getter methods. For example in setEstimatedDepartureTime() if the item is out of range it should set to either the earliest or the latest depending on what side it is out of bounds on and not the default

Also need to add an error check to Segment.setMode(). We need a method to check that a parameter is within a set enumeration. For example

isEnumerated(List, Parameter) { This function would check that the parameter is within the list.
}

An example call would be FormatChecker.isEnumerated(Vehicle.TravelModes,RAIL)

A way you can test this is after it is implemented the JUnit test testSetMode should pass because it should accept everything in test-string-good[] as vaild and everything in test-string-bad as invalid

Also can you add error checking to segment.setActual capacity so that it only accepts value >=0 and any negative value passed in is set as 0. Doing this will ensure that testSetActualCapacity will pass

zgp1001 commented 10 years ago

The current set up requires latest times to be set before earliest time, other wise your tests fail because the earliest time never gets set to what you expect it to be (as earliest time cant be set to 500 until latest time is bigger than that).

You'll notice switching the setters will end up with only 1 failure (the modes test - which I'm writing a function for now).

Do we want to change this or is this reasonable behavior?