01: /*
02: * This file is part of JGAP.
03: *
04: * JGAP offers a dual license model containing the LGPL as well as the MPL.
05: *
06: * For licensing information please see the file license.txt included with JGAP
07: * or have a look at the top of class org.jgap.Chromosome which representatively
08: * includes the JGAP license policy applicable for any file delivered with JGAP.
09: */
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 extends JGAPTestCase {
21: /** String containing the CVS revision. Read out via reflection!*/
22: private final static String CVS_REVISION = "$Revision: 1.10 $";
23:
24: public static Test suite() {
25: TestSuite suite = new TestSuite(DeltaFitnessEvaluatorTest.class);
26: return suite;
27: }
28:
29: public void testIsFitter_0() {
30: FitnessEvaluator evaluator = new DeltaFitnessEvaluator();
31: assertEquals(false, evaluator.isFitter(1, 0));
32: assertEquals(true, evaluator.isFitter(0, 1));
33: }
34:
35: public void testIsFitter_1() {
36: FitnessEvaluator evaluator = new DeltaFitnessEvaluator();
37: assertEquals(false, evaluator.isFitter(12, 11));
38: assertEquals(true, evaluator.isFitter(11, 12));
39: }
40:
41: public void testIsFitter_2() {
42: FitnessEvaluator evaluator = new DeltaFitnessEvaluator();
43: assertEquals(false, evaluator.isFitter(-1, 1));
44: assertEquals(true, evaluator.isFitter(1, -1));
45: }
46:
47: public void testIsFitter_3() {
48: FitnessEvaluator evaluator = new DeltaFitnessEvaluator();
49: assertEquals(false, evaluator.isFitter(0, 0));
50: }
51:
52: public void testIsFitter_4() {
53: FitnessEvaluator evaluator = new DeltaFitnessEvaluator();
54: assertEquals(false, evaluator.isFitter(-4, -4));
55: }
56:
57: public void testIsFitter_5() {
58: FitnessEvaluator evaluator = new DeltaFitnessEvaluator();
59: assertEquals(false, evaluator.isFitter(-3, -1));
60: assertEquals(false, evaluator.isFitter(-1, -3));
61: }
62:
63: public void testIsFitter_6() throws Exception {
64: Configuration conf = new ConfigurationForTesting();
65: FitnessEvaluator evaluator = new DeltaFitnessEvaluator();
66: Chromosome chrom1 = new Chromosome(conf);
67: chrom1.setFitnessValue(2);
68: Chromosome chrom2 = new Chromosome(conf);
69: chrom2.setFitnessValue(2);
70: assertEquals(false, evaluator.isFitter(chrom1, chrom2));
71: assertEquals(false, evaluator.isFitter(chrom2, chrom1));
72: chrom2.setFitnessValue(3);
73: assertEquals(true, evaluator.isFitter(chrom1, chrom2));
74: assertEquals(false, evaluator.isFitter(chrom2, chrom1));
75: }
76: }
|