コード例 #1
0
  @Test
  public void testCompadability() {
    PrimeIdentifier pi = new PrimeIdentifier();

    for (Integer v : (new EratosthenesPrimeSearch()).getPrimesLessThan(1000000)) {
      assertTrue(pi.isPrime(v));
    }
  }
コード例 #2
0
  @Test
  public void testPrimes() {
    boolean[] primes = {
      false, false, true, true, false, true, false, true, false, false, false, true, false, true
    };
    PrimeIdentifier pi = new PrimeIdentifier();

    for (int i = -1; i < primes.length; ++i) {
      assertEquals(pi.isPrime(i), i >= 0 ? primes[i] : false);
    }
  }