1 10 package org.jgap.distr; 11 12 import org.jgap.*; 13 import org.jgap.impl.*; 14 15 import junit.framework.*; 16 17 23 public class ProblemTest 24 extends JGAPTestCase { 25 26 private static final String CVS_REVISION = "$Revision: 1.1 $"; 27 28 public static Test suite() { 29 TestSuite suite = new TestSuite(ProblemTest.class); 30 return suite; 31 } 32 33 37 public void testConstruct_0() { 38 try { 39 new Problem(null, 3, null); 40 fail(); 41 } 42 catch (IllegalArgumentException iex) { 43 ; } 45 } 46 47 51 public void testConstruct_1() { 52 try { 53 new Problem(new StaticFitnessFunction(4.5d), 0, null); 54 fail(); 55 } 56 catch (IllegalArgumentException iex) { 57 ; } 59 } 60 61 65 public void testConstruct_2() { 66 try { 67 new Problem(new StaticFitnessFunction(4.5d), -1, null); 68 fail(); 69 } 70 catch (IllegalArgumentException iex) { 71 ; } 73 } 74 75 81 public void testConstruct_3() throws Exception { 82 FitnessFunction ff = new StaticFitnessFunction(4.5d); 83 Chromosome c = new Chromosome(conf); 84 Chromosome[] chroms = new Chromosome[]{c}; 85 Problem p = new Problem(ff, 23, chroms); 86 assertEquals(23, p.getPopulationSize()); 87 assertSame(ff, p.getFitnessFunction()); 88 assertSame(chroms, p.getChromosomes()); 89 } 90 91 97 public void testGetID_0() throws Exception { 98 Problem p = new Problem(); 99 String s = "2aXh-"; 100 p.setID(s); 101 assertSame(s, p.getID()); 102 } 103 } 104 | Popular Tags |