1 10 package org.jgap; 11 12 import junit.framework.*; 13 14 20 public final class DeltaFitnessEvaluatorTest 21 extends JGAPTestCase { 22 23 private final static String CVS_REVISION = "$Revision: 1.8 $"; 24 25 public static Test suite() { 26 TestSuite suite = new TestSuite(DeltaFitnessEvaluatorTest.class); 27 return suite; 28 } 29 30 public void testIsFitter_0() { 31 FitnessEvaluator evaluator = new DeltaFitnessEvaluator(); 32 assertEquals(false, evaluator.isFitter(1, 0)); 33 assertEquals(true, evaluator.isFitter(0, 1)); 34 } 35 36 public void testIsFitter_1() { 37 FitnessEvaluator evaluator = new DeltaFitnessEvaluator(); 38 assertEquals(false, evaluator.isFitter(12, 11)); 39 assertEquals(true, evaluator.isFitter(11, 12)); 40 } 41 42 public void testIsFitter_2() { 43 FitnessEvaluator evaluator = new DeltaFitnessEvaluator(); 44 assertEquals(false, evaluator.isFitter( -1, 1)); 45 assertEquals(true, evaluator.isFitter(1, -1)); 46 } 47 48 public void testIsFitter_3() { 49 FitnessEvaluator evaluator = new DeltaFitnessEvaluator(); 50 assertEquals(false, evaluator.isFitter(0, 0)); 51 } 52 53 public void testIsFitter_4() { 54 FitnessEvaluator evaluator = new DeltaFitnessEvaluator(); 55 assertEquals(false, evaluator.isFitter( -4, -4)); 56 } 57 58 public void testIsFitter_5() { 59 FitnessEvaluator evaluator = new DeltaFitnessEvaluator(); 60 assertEquals(false, evaluator.isFitter( -3, -1)); 61 assertEquals(false, evaluator.isFitter( -1, -3)); 62 } 63 64 public void testIsFitter_6() 65 throws Exception { 66 Configuration conf = new ConfigurationForTest(); 67 FitnessEvaluator evaluator = new DeltaFitnessEvaluator(); 68 Chromosome chrom1 = new Chromosome(conf); 69 chrom1.setFitnessValue(2); 70 Chromosome chrom2 = new Chromosome(conf); 71 chrom2.setFitnessValue(2); 72 assertEquals(false, evaluator.isFitter(chrom1, chrom2)); 73 assertEquals(false, evaluator.isFitter(chrom2, chrom1)); 74 chrom2.setFitnessValue(3); 75 assertEquals(true, evaluator.isFitter(chrom1, chrom2)); 76 assertEquals(false, evaluator.isFitter(chrom2, chrom1)); 77 } 78 } 79 | Popular Tags |