Skip to content

Commit c6a22de

Browse files
lukasb1bvil02
andauthored
Add MinValueTest and remove main from MinValue (#4713)
* Update MinValue.java * Create MinValueTest.java * Revert "Create MinValueTest.java" * Create MinValueTest.java * Update MinValueTest.java * Update MinValueTest.java * Update MinValue.java * Update src/test/java/com/thealgorithms/maths/MinValueTest.java Co-authored-by: Piotr Idzik <[email protected]> * Update src/test/java/com/thealgorithms/maths/MinValueTest.java Co-authored-by: Piotr Idzik <[email protected]> * Update src/main/java/com/thealgorithms/maths/MinValue.java Co-authored-by: Piotr Idzik <[email protected]> --------- Co-authored-by: Piotr Idzik <[email protected]>
1 parent facc62a commit c6a22de

File tree

2 files changed

+16
-18
lines changed

2 files changed

+16
-18
lines changed

src/main/java/com/thealgorithms/maths/MinValue.java

+2-18
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,8 @@
11
package com.thealgorithms.maths;
22

3-
import java.util.Random;
4-
5-
public class MinValue {
6-
7-
/**
8-
* Driver Code
9-
*/
10-
public static void main(String[] args) {
11-
Random rand = new Random();
12-
13-
/* test 100 times using rand numbers */
14-
for (int i = 1; i <= 100; ++i) {
15-
/* generate number from -50 to 49 */
16-
int a = rand.nextInt(100) - 50;
17-
int b = rand.nextInt(100) - 50;
18-
assert min(a, b) == Math.min(a, b);
19-
}
3+
public final class MinValue {
4+
private MinValue() {
205
}
21-
226
/**
237
* Returns the smaller of two {@code int} values. That is, the result the
248
* argument closer to the value of {@link Integer#MIN_VALUE}. If the
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.thealgorithms.maths;
2+
3+
import static org.junit.jupiter.api.Assertions.assertEquals;
4+
5+
import org.junit.jupiter.api.Test;
6+
7+
public class MinValueTest {
8+
@Test
9+
public void minTest() {
10+
assertEquals(-1, MinValue.min(-1, 3));
11+
assertEquals(2, MinValue.min(3, 2));
12+
assertEquals(5, MinValue.min(5, 5));
13+
}
14+
}

0 commit comments

Comments
 (0)