Skip to content

Add MinValueTest and remove main from MinValue #4713

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Oct 9, 2023
Merged
18 changes: 0 additions & 18 deletions src/main/java/com/thealgorithms/maths/MinValue.java
Original file line number Diff line number Diff line change
@@ -1,24 +1,6 @@
package com.thealgorithms.maths;

import java.util.Random;

public class MinValue {

/**
* 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 min(a, b) == Math.min(a, b);
}
}

/**
* Returns the smaller of two {@code int} values. That is, the result the
* argument closer to the value of {@link Integer#MIN_VALUE}. If the
Expand Down
13 changes: 13 additions & 0 deletions src/test/java/com/thealgorithms/maths/MinValueTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.thealgorithms.maths;

import static org.junit.jupiter.api.Assertions.assertEquals;

import org.junit.jupiter.api.Test;

public class MinValueTest {
@Test
public void flipBitTest() {
assertEquals(-1, MinValue.min(-1, 3));
assertEquals(2, MinValue.min(3, 2));
}
}