1 10 package org.jgap.impl; 11 12 import org.jgap.*; 13 import junit.framework.*; 14 15 21 public class ChromosomePoolTest 22 extends JGAPTestCase { 23 24 private final static String CVS_REVISION = "$Revision: 1.9 $"; 25 26 public static Test suite() { 27 TestSuite suite = new TestSuite(ChromosomePoolTest.class); 28 return suite; 29 } 30 31 public void setUp() { 32 super.setUp(); 33 Configuration.reset(); 34 } 35 36 43 public void testConstruct_0() throws Exception { 44 ChromosomePool pool = new ChromosomePool(); 45 Pool p = (Pool)privateAccessor.getField(pool, "m_chromosomePool"); 46 assertNotNull(p); 47 } 48 49 53 public void testAquireChromosome_0() { 54 assertEquals(null, new ChromosomePool().acquireChromosome()); 55 } 56 57 61 public void testReleaseChromosome_0() { 62 try { 63 new ChromosomePool().releaseChromosome(null); 64 fail(); 65 } 66 catch (IllegalArgumentException nex) { 67 ; } 69 } 70 71 78 public void testReleaseChromosome_1() 79 throws Exception { 80 ChromosomePool pool = new ChromosomePool(); 81 Configuration conf = new DefaultConfiguration(); 82 conf.setFitnessFunction(new TestFitnessFunction()); 83 conf.setPopulationSize(5); 84 Gene sampleGene = new IntegerGene(conf, 1, 10); 85 Chromosome chrom = new Chromosome(conf, sampleGene, 3); 86 conf.setSampleChromosome(chrom); 87 pool.releaseChromosome(chrom); 88 } 89 } 90 | Popular Tags |