diff --git a/src/main/java/com/thealgorithms/maths/MaxValue.java b/src/main/java/com/thealgorithms/maths/MaxValue.java index a4603533..d8829106 100644 --- a/src/main/java/com/thealgorithms/maths/MaxValue.java +++ b/src/main/java/com/thealgorithms/maths/MaxValue.java @@ -1,24 +1,8 @@ package com.thealgorithms.maths; -import java.util.Random; - -public class MaxValue { - - /** - * Driver Code - */ - public static void main(String[] args) { - Random rand = new Random(); - - /* test 100 times using rand numbers */ - for (int i = 1; i <= 100; ++i) { - /* generate number from -50 to 49 */ - int a = rand.nextInt(100) - 50; - int b = rand.nextInt(100) - 50; - assert max(a, b) == Math.max(a, b); - } +public final class MaxValue { + private MaxValue() { } - /** * Returns the greater of two {@code int} values. That is, the result is the * argument closer to the value of {@link Integer#MAX_VALUE}. If the diff --git a/src/test/java/com/thealgorithms/maths/MaxValueTest.java b/src/test/java/com/thealgorithms/maths/MaxValueTest.java new file mode 100644 index 00000000..3c0fe844 --- /dev/null +++ b/src/test/java/com/thealgorithms/maths/MaxValueTest.java @@ -0,0 +1,14 @@ +package com.thealgorithms.maths; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Test; + +public class MaxValueTest { + @Test + public void maxTest() { + assertEquals(-1, MaxValue.max(-1, -3)); + assertEquals(3, MaxValue.max(3, 2)); + assertEquals(5, MaxValue.max(5, 5)); + } +}