File tree 2 files changed +16
-18
lines changed
main/java/com/thealgorithms/maths
test/java/com/thealgorithms/maths
2 files changed +16
-18
lines changed Original file line number Diff line number Diff line change 1
1
package com .thealgorithms .maths ;
2
2
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 () {
20
5
}
21
-
22
6
/**
23
7
* Returns the smaller of two {@code int} values. That is, the result the
24
8
* argument closer to the value of {@link Integer#MIN_VALUE}. If the
Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments