From c392ee6c26600a9a10960878019ea35637846b76 Mon Sep 17 00:00:00 2001 From: fdai7430 Date: Sat, 4 Feb 2023 19:53:37 +0100 Subject: [PATCH] unittest: Added test for testRunawaySucceeds() --- .../java/org/bitbiome/commands/UseCommandTest.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/test/java/org/bitbiome/commands/UseCommandTest.java b/src/test/java/org/bitbiome/commands/UseCommandTest.java index 343c1b5..d9a1710 100644 --- a/src/test/java/org/bitbiome/commands/UseCommandTest.java +++ b/src/test/java/org/bitbiome/commands/UseCommandTest.java @@ -1,6 +1,7 @@ package org.bitbiome.commands; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.ArrayList; @@ -35,6 +36,15 @@ public class UseCommandTest { assertEquals(100, com.getRunawayChance()); } + @Test + public void testRunawaySucceeds() { + UseCommand com = new UseCommand(); + assertEquals(true, com.runawaySucceeds(0)); + assertEquals(false, com.runawaySucceeds(101)); + int random = (int)(Math.random()*100); + assertTrue(com.runawaySucceeds(random) || !com.runawaySucceeds(random)); + } + @Test public void testUseItemMob() { UseCommand com = new UseCommand();