File tree Expand file tree Collapse file tree 2 files changed +16
-18
lines changed
main/java/com/thealgorithms/maths
test/java/com/thealgorithms/maths Expand file tree Collapse file tree 2 files changed +16
-18
lines changed Original file line number Diff line number Diff line change 11package com .thealgorithms .maths ;
22
3- import java .util .Random ;
4-
5- public class MaxValue {
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 max (a , b ) == Math .max (a , b );
19- }
3+ public final class MaxValue {
4+ private MaxValue () {
205 }
21-
226 /**
237 * Returns the greater of two {@code int} values. That is, the result is the
248 * argument closer to the value of {@link Integer#MAX_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 MaxValueTest {
8+ @ Test
9+ public void maxTest () {
10+ assertEquals (-1 , MaxValue .max (-1 , -3 ));
11+ assertEquals (3 , MaxValue .max (3 , 2 ));
12+ assertEquals (5 , MaxValue .max (5 , 5 ));
13+ }
14+ }
You can’t perform that action at this time.
0 commit comments