### Question:
Population { public void evolve() { Chromosome[] buffer = new Chromosome[popArr.length]; int idx = Math.round(popArr.length * elitism); System.arraycopy(popArr, 0, buffer, 0, idx); while (idx < buffer.length) { if (rand.nextFloat() <= crossover) { Chromosome[] parents = selectParents(); Chromosome[] children = parents[0].mate(parents[1]); if (rand.nextFloat() <= mutation) { buffer[idx++] = children[0].mutate(); } else { buffer[idx++] = children[0]; } if (idx < buffer.length) { if (rand.nextFloat() <= mutation) { buffer[idx] = children[1].mutate(); } else { buffer[idx] = children[1]; } } } else { if (rand.nextFloat() <= mutation) { buffer[idx] = popArr[idx].mutate(); } else { buffer[idx] = popArr[idx]; } } ++idx; } Arrays.sort(buffer); popArr = buffer; } Population(int size, float crossoverRatio, float elitismRatio, 
			float mutationRatio); void evolve(); Chromosome[] getPopulation(); float getElitism(); float getCrossover(); float getMutation();  }### Answer:
@Test public void testEvolve() { Population pop = new Population(1024, 0.8f, 0.1f, 0.05f); Chromosome[] oldArr = pop.getPopulation(); pop.evolve(); Chromosome[] newArr = pop.getPopulation(); assertEquals(80, (int) (pop.getCrossover() * 100)); assertEquals(10, (int) (pop.getElitism() * 100)); assertEquals(5, (int) (pop.getMutation() * 100)); final int elitismCount = Math.round(1024 * 0.1f); int counter = 0; for (int i = 0; i < oldArr.length; i++) { if (Arrays.binarySearch(newArr, oldArr[i]) >= 0) { ++counter; } } assertTrue(counter >= elitismCount); assertTrue(counter < oldArr.length); }