1 10 package org.jgap.impl; 11 12 import org.jgap.*; 13 import junit.framework.*; 14 15 21 public class DefaultCrossoverRateCalculatorTest 22 extends JGAPTestCase { 23 24 private static final String CVS_REVISION = "$Revision: 1.11 $"; 25 26 public static Test suite() { 27 TestSuite suite = new TestSuite(DefaultCrossoverRateCalculatorTest.class); 28 return suite; 29 } 30 31 public void setUp() { 32 super.setUp(); 33 Configuration.reset(); 35 } 36 37 43 public void testCalculateCurrentRate_0() 44 throws Exception { 45 IUniversalRateCalculator calc = new DefaultCrossoverRateCalculator(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_01() 60 throws Exception { 61 IUniversalRateCalculator calc = new DefaultCrossoverRateCalculator(conf); 62 Gene gene = new IntegerGene(conf, 1, 5); 63 Chromosome chrom = new Chromosome(conf, gene, 30); 64 conf.setSampleChromosome(chrom); 65 int rate = calc.calculateCurrentRate(); 66 assertEquals(conf.getChromosomeSize(), rate); 67 } 68 69 78 public void testCalculateCurrentRate_1() 79 throws Exception { 80 IUniversalRateCalculator calc = new DefaultCrossoverRateCalculator(conf); 81 int rate = calc.calculateCurrentRate(); 82 assertEquals(1, rate); 83 } 84 85 91 public void testToBePermutated_0() 92 throws Exception { 93 IUniversalRateCalculator calc = new DefaultCrossoverRateCalculator(conf); 94 assertTrue(calc.toBePermutated(null, 0)); 95 } 96 } 97 | Popular Tags |