APL/DEV 2.3/Largest/TestLargest.java

36 lines
795 B
Java
Raw Permalink Normal View History

2022-06-01 12:19:24 +02:00
import static org.junit.Assert.assertEquals;
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, 28825, Integer.MAX_VALUE}));
}
@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[] {3, 1, 7}) == a[a.length-1]);
}
@Test
public void testError() {
Largest.largest(new int[] {});
Largest.largest(null);
}
}