1 10 package org.jgap.impl; 11 12 import org.jgap.*; 13 14 import junit.framework.*; 15 16 22 public class DefaultMutationRateCalculatorTest 23 extends JGAPTestCase { 24 25 26 private static final String CVS_REVISION = "$Revision: 1.12 $"; 27 28 public static Test suite() { 29 TestSuite suite = new TestSuite(DefaultMutationRateCalculatorTest.class); 30 return suite; 31 } 32 33 public void setUp() { 34 super.setUp(); 35 Configuration.reset(); 37 } 38 39 44 public void testCalculateCurrentRate_0() throws Exception { 45 IUniversalRateCalculator calc = new DefaultMutationRateCalculator(conf); 46 Gene gene = new IntegerGene(conf, 1, 5); 47 Chromosome chrom = new Chromosome(conf, gene, 50); 48 conf.setSampleChromosome(chrom); 49 int rate = calc.calculateCurrentRate(); 50 assertEquals(conf.getChromosomeSize(), rate); 51 } 52 53 59 public void testCalculateCurrentRate_1() throws Exception { 60 IUniversalRateCalculator calc = new DefaultMutationRateCalculator(conf); 61 Gene gene = new IntegerGene(conf, 1, 5); 62 Chromosome chrom = new Chromosome(conf, gene, 30); 63 conf.setSampleChromosome(chrom); 64 int rate = calc.calculateCurrentRate(); 65 assertEquals(conf.getChromosomeSize(), rate); 66 } 67 68 76 public void testCalculateCurrentRate_2() throws Exception { 77 IUniversalRateCalculator calc = new DefaultMutationRateCalculator(conf); 78 int rate = calc.calculateCurrentRate(); 79 assertEquals(1, rate); 80 } 81 } 82 | Popular Tags |