public class BiggerNum{ /** * @param a integer of param1 * @param b integer of param2 * @return the bigger integer of a and b * If a equals b, eiter one is acceptance */ public static int compare(int a, int b) { return a >= b ? a : b; } }
- public class BiggerNum{
- /**
- * @param a integer of param1
- * @param b integer of param2
- * @return the bigger integer of a and b
- * If a equals b, eiter one is acceptance
- */
- public static int compare(int a, int b) {
if(a > b){return a;}else{return b;}- return a >= b ? a : b;
- }
- }
import org.junit.Test; import static org.junit.Assert.assertEquals; import org.junit.runners.JUnit4; // TODO: Replace examples and use TDD development by writing your own tests public class SolutionTest { @Test public void should_return_a_when_a_gt_b() { int a = 10; int b = 5; assertEquals(a, BiggerNum.compare(a, b)); } @Test public void should_return_b_when_a_lt_b() { int a = 4; int b = 5; assertEquals(b, BiggerNum.compare(a, b)); } @Test public void should_return_either_when_a_eq_b() { int a = 5; int b = 5; assertEquals(5, BiggerNum.compare(a, b)); } }
- import org.junit.Test;
- import static org.junit.Assert.assertEquals;
- import org.junit.runners.JUnit4;
- // TODO: Replace examples and use TDD development by writing your own tests
- public class SolutionTest {
- @Test
public void testSomething() {- public void should_return_a_when_a_gt_b() {
- int a = 10;
- int b = 5;
assertEquals(10, BiggerNum.compare(a, b));- assertEquals(a, BiggerNum.compare(a, b));
- }
- @Test
- public void should_return_b_when_a_lt_b() {
- int a = 4;
- int b = 5;
- assertEquals(b, BiggerNum.compare(a, b));
- }
- @Test
- public void should_return_either_when_a_eq_b() {
- int a = 5;
- int b = 5;
- assertEquals(5, BiggerNum.compare(a, b));
- }
- }
Return the bigger integer
public class BiggerNum{
public static int compare(int a, int b) {
return 0;
}
}
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import org.junit.runners.JUnit4;
// TODO: Replace examples and use TDD development by writing your own tests
public class SolutionTest {
@Test
public void testSomething() {
int a = 10;
int b = 5;
//assertEquals(10, BiggerNum.compare(a, b));
}
}