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

Change-Id: I3a3b368d429dc5cd00baf94ccd80a676a10cbb48
This commit is contained in:
Jonathan Leitschuh
2014-07-17 15:51:01 -04:00
parent d0fdb3e704
commit 437e3ff266
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) {