Merge "Adds a Unit Test for the Resource object in Java. Fixes a bug in the Resource class caused by allocating a negative resource value."

This commit is contained in:
Thomas Clark (WPI)
2014-07-17 12:55:24 -07:00
committed by Gerrit Code Review
2 changed files with 132 additions and 1 deletions

View File

@@ -86,7 +86,7 @@ public class Resource {
* @throws CheckedAllocationException If there are no resources available to be allocated.
*/
public int allocate(final int index) throws CheckedAllocationException {
if (index >= m_size) {
if (index >= m_size || index < 0) {
throw new CheckedAllocationException("Index " + index + " out of range");
}
if (m_numAllocated[index] == true) {