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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 2 additions & 18 deletions src/main/java/com/thealgorithms/maths/MinValue.java
Original file line number Diff line number Diff line change
@@ -1,24 +1,8 @@
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);
}
public final class MinValue {
private MinValue() {
}

/**
* 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
14 changes: 14 additions & 0 deletions src/test/java/com/thealgorithms/maths/MinValueTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.thealgorithms.maths;

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

import org.junit.jupiter.api.Test;

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