### Question:
Library { public static int[] listPrimes(int n) { boolean[] isPrime = listPrimality(n); int count = 0; for (boolean b : isPrime) { if (b) count++; } int[] result = new int[count]; for (int i = 0, j = 0; i < isPrime.length; i++) { if (isPrime[i]) { result[j] = i; j++; } } return result; }  static String reverse(String s); static boolean isPalindrome(String s); static boolean isPalindrome(int x); static int sqrt(int x); static long sqrt(long x); static BigInteger sqrt(BigInteger x); static boolean isSquare(int x); static int pow(int x, int y); static int powMod(int x, int y, int m); static int reciprocalMod(int x, int m); static BigInteger factorial(int n); static BigInteger binomial(int n, int k); static int gcd(int x, int y); static boolean isPrime(int x); static boolean[] listPrimality(int n); static int[] listPrimes(int n); static int[] listSmallestPrimeFactors(int n); static int totient(int n); static int[] listTotients(int n); static boolean nextPermutation(int[] arr);  }### Answer:
@Test public void testListPrimes() { int limit = 1000; int[] primes = Library.listPrimes(limit); for (int i = 0; i < primes.length - 1; i++) assertTrue(primes[i] < primes[i + 1]); for (int i = 0; i <= limit; i++) assertEquals(Library.isPrime(i), Arrays.binarySearch(primes, i) >= 0); }
@Test(expected=IllegalArgumentException.class) public void testListPrimesInvalid0() { Library.listPrimes(-1); }
@Test(expected=IllegalArgumentException.class) public void testListPrimesInvalid1() { Library.listPrimes(-3000); }