From e9e80310abb1c88f9c2d8375ff51ec28cd1722a8 Mon Sep 17 00:00:00 2001 From: Der-Schubi Date: Wed, 20 Dec 2023 12:16:38 +0100 Subject: [PATCH] Fix Tests: Block.set: Do not return null pointer --- .../dexdrip/utils/math/BlockFinder.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/eveningoutpost/dexdrip/utils/math/BlockFinder.java b/app/src/main/java/com/eveningoutpost/dexdrip/utils/math/BlockFinder.java index daa4679324..51cbe0612b 100644 --- a/app/src/main/java/com/eveningoutpost/dexdrip/utils/math/BlockFinder.java +++ b/app/src/main/java/com/eveningoutpost/dexdrip/utils/math/BlockFinder.java @@ -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; } } @@ -107,7 +112,7 @@ public int findRandomAvailablePositionWithFailSafe(final int height, final int m } } // FailSafe - return new Random().nextInt(maxHeight); + return new Random().nextInt(bound); }