34 lines
774 B
Java
34 lines
774 B
Java
|
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() {
|
||
|
}*/
|
||
|
}
|