Skip to content

Commit

Permalink
Fix Tests: Block.set: Do not return null pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
Der-Schubi committed Jan 24, 2024
1 parent 8bc0d6d commit e9e8031
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,14 @@ public String toString() {
}

public Block set(final int top, final int bottom) {
if (top < 0 || bottom < 0) return null;
this.top = top;
this.bottom = bottom;
if (top < 0 || bottom < 0)
{
this.top = 0;
this.bottom = 0;
} else {
this.top = top;
this.bottom = bottom;
}
return this;
}
}
Expand Down Expand Up @@ -107,7 +112,7 @@ public int findRandomAvailablePositionWithFailSafe(final int height, final int m
}
}
// FailSafe
return new Random().nextInt(maxHeight);
return new Random().nextInt(bound);
}


Expand Down

0 comments on commit e9e8031

Please sign in to comment.