Developpement/23DEV1.1/TPS2/TP01/junit/TP2/TestLargest.java

34 lines
774 B
Java
Raw Normal View History

2024-12-09 11:53:11 +01:00
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import java.util.Arrays;
import org.junit.Test;
public class TestLargest {
@Test
public void testSimple() {
assertEquals(9, Largest.largest(new int[] {9,8,7}));
}
@Test
public void testBoundary() {
assertEquals(Integer.MAX_VALUE, Largest.largest(new int[] {1,200}));
}
@Test
public void testInverse() {
assert(3!=Largest.largest(new int[] {1,3,7}));
}
@Test
public void testCrosscheck() {
int[] a = new int[] {3,1,7};
Arrays.sort(a);
assert(Largest.largest(new int[] {1,3,7}) == a[a.length-1]);
}
@Test
public void testForceError() {
Largest.largest(new int[] {});
Largest.largest(null);
}
/*@Test
public void testPerformCharacter() {
}*/
}