KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jgap > DeltaFitnessEvaluatorTest


1 /*
2  * This file is part of JGAP.
3  *
4  * JGAP offers a dual license model containing the LGPL as well as the MPL.
5  *
6  * For licencing information please see the file license.txt included with JGAP
7  * or have a look at the top of class org.jgap.Chromosome which representatively
8  * includes the JGAP license policy applicable for any file delivered with JGAP.
9  */

10 package org.jgap;
11
12 import junit.framework.*;
13
14 /**
15  * Test cases for class DeltaFitnessEvaluator.
16  *
17  * @author Klaus Meffert
18  * @since 2.2
19  */

20 public final class DeltaFitnessEvaluatorTest
21     extends JGAPTestCase {
22   /** String containing the CVS revision. Read out via reflection!*/
23   private final static String JavaDoc 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 JavaDoc {
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