📄 booleangenetest.java
字号:
/**
* @throws Exception
*
* @author Klaus Meffert
* @since 3.1
*/
public void testCompareTo_6_3()
throws Exception {
Gene gene1 = new BooleanGene(conf);
gene1.setAllele(Boolean.FALSE);
Gene gene2 = new BooleanGene(conf);
gene2.setAllele(Boolean.FALSE);
gene1.setCompareApplicationData(true);
gene2.setCompareApplicationData(true);
List app1 = new Vector();
gene1.setApplicationData(app1);
assertEquals(1, gene1.compareTo(gene2));
assertEquals(-1, gene2.compareTo(gene1));
}
/**
* @throws Exception
*
* @author Klaus Meffert
* @since 3.1
*/
public void testCompareTo_7()
throws Exception {
Gene gene1 = new BooleanGene(conf);
Gene gene2 = new BooleanGene(conf);
gene2.setAllele(Boolean.TRUE);
assertEquals(-1, gene1.compareTo(gene2));
assertEquals(1, gene2.compareTo(gene1));
}
/**
* @throws Exception
*
* @author Klaus Meffert
*/
public void testApplyMutation_0()
throws Exception {
BooleanGene gene = new BooleanGene(conf);
gene.setAllele(Boolean.valueOf(true));
gene.applyMutation(0, 0.0d);
assertEquals(true, gene.booleanValue());
}
/**
* @throws Exception
*
* @author Klaus Meffert
*/
public void testApplyMutation_1()
throws Exception {
BooleanGene gene = new BooleanGene(conf);
gene.setAllele(Boolean.valueOf(true));
gene.applyMutation(1, 0.000001d); //index 1 should be ignored
assertEquals(true, gene.booleanValue());
}
/**
* @throws Exception
*
* @author Klaus Meffert
*/
public void testApplyMutation_2()
throws Exception {
BooleanGene gene = new BooleanGene(conf);
gene.setAllele(Boolean.valueOf(true));
gene.applyMutation(333, -0.000001d); //index 333 should be ignored
assertEquals(false, gene.booleanValue());
}
/**
* @throws Exception
*
* @author Klaus Meffert
*/
public void testApplyMutation_3()
throws Exception {
BooleanGene gene = new BooleanGene(conf);
gene.setAllele(Boolean.valueOf(true));
gene.applyMutation(0, -1.0d);
assertEquals(false, gene.booleanValue());
}
/**
* @throws Exception
*
* @author Klaus Meffert
*/
public void testApplyMutation_4()
throws Exception {
BooleanGene gene = new BooleanGene(conf);
gene.setAllele(Boolean.valueOf(true));
gene.applyMutation(0, -2.0d);
assertEquals(false, gene.booleanValue());
}
/**
* @throws Exception
*
* @author Klaus Meffert
*/
public void testApplyMutation_5()
throws Exception {
BooleanGene gene = new BooleanGene(conf);
gene.setAllele(Boolean.valueOf(true));
gene.applyMutation(0, 2.0d);
assertEquals(true, gene.booleanValue());
}
/**
* @throws Exception
*
* @author Klaus Meffert
*/
public void testApplyMutation_6()
throws Exception {
BooleanGene gene = new BooleanGene(conf);
gene.setAllele(Boolean.valueOf(false));
gene.applyMutation(0, 2.0d);
assertEquals(true, gene.booleanValue());
}
/**
* @throws Exception
*
* @author Klaus Meffert
*/
public void testApplyMutation_7()
throws Exception {
BooleanGene gene = new BooleanGene(conf);
gene.setAllele(Boolean.valueOf(false));
gene.applyMutation(0, -1.0d);
assertEquals(false, gene.booleanValue());
}
/**
* @throws Exception
*
* @author Klaus Meffert
*/
public void testApplyMutation_8()
throws Exception {
BooleanGene gene = new BooleanGene(conf);
gene.setAllele(Boolean.valueOf(false));
gene.applyMutation(22, -0.5d); //22 should be ignored
assertEquals(false, gene.booleanValue());
}
/**
* @throws Exception
*
* @author Klaus Meffert
*/
public void testApplyMutation_9()
throws Exception {
BooleanGene gene = new BooleanGene(conf);
gene.setAllele(Boolean.valueOf(false));
gene.applyMutation(22, 0.5d); //22 should be ignored
assertEquals(true, gene.booleanValue());
}
/**
* @throws Exception
*
* @author Klaus Meffert
* @since 2.2
*/
public void testApplyMutation_10()
throws Exception {
BooleanGene gene = new BooleanGene(conf);
gene.applyMutation(0, 0.0d);
assertEquals(false, gene.booleanValue());
}
/**
* @throws Exception
*
* @author Klaus Meffert
* @since 2.0
*/
public void testSetValueFromPersistentRepresentation_0()
throws Exception {
BooleanGene gene = new BooleanGene(conf);
try {
gene.setValueFromPersistentRepresentation(null);
fail();
} catch (UnsupportedRepresentationException uex) {
; //this is OK
}
}
/**
* @throws Exception
*
* @author Klaus Meffert
* @since 2.0
*/
public void testSetValueFromPersistentRepresentation_1()
throws Exception {
BooleanGene gene = new BooleanGene(conf);
gene.setValueFromPersistentRepresentation("null");
assertEquals(null, gene.getAllele());
}
/**
* @throws Exception
*
* @author Klaus Meffert
* @since 2.0
*/
public void testSetValueFromPersistentRepresentation_2()
throws Exception {
BooleanGene gene = new BooleanGene(conf);
gene.setValueFromPersistentRepresentation("true");
assertEquals(Boolean.TRUE, gene.getAllele());
}
/**
* @throws Exception
*
* @author Klaus Meffert
* @since 2.0
*/
public void testSetValueFromPersistentRepresentation_3()
throws Exception {
BooleanGene gene = new BooleanGene(conf);
gene.setValueFromPersistentRepresentation("false");
assertEquals(Boolean.FALSE, gene.getAllele());
}
/**
* @throws Exception
*
* @author Klaus Meffert
* @since 2.0
*/
public void testSetValueFromPersistentRepresentation_4()
throws Exception {
BooleanGene gene = new BooleanGene(conf);
try {
gene.setValueFromPersistentRepresentation("True");
fail();
} catch (UnsupportedRepresentationException uex) {
; //this is OK
}
}
/**
* @throws Exception
*
* @author Klaus Meffert
* @since 2.0
*/
public void testSetValueFromPersistentRepresentation_5()
throws Exception {
BooleanGene gene = new BooleanGene(conf);
try {
gene.setValueFromPersistentRepresentation("False");
fail();
} catch (UnsupportedRepresentationException uex) {
; //this is OK
}
}
/**
* @throws Exception
*
* @author Klaus Meffert
* @since 2.0
*/
public void testSetValueFromPersistentRepresentation_6()
throws Exception {
BooleanGene gene = new BooleanGene(conf);
try {
gene.setValueFromPersistentRepresentation("X");
fail();
} catch (UnsupportedRepresentationException uex) {
; //this is OK
}
}
/**
* @throws Exception
*
* @author Klaus Meffert
*/
public void testGetPersistentRepresentation_0()
throws Exception {
BooleanGene gene = new BooleanGene(conf);
gene.setAllele(Boolean.valueOf(true));
String s = gene.getPersistentRepresentation();
assertEquals("true", s);
}
/**
* @throws Exception
*
* @author Klaus Meffert
*/
public void testGetPersistentRepresentation_1()
throws Exception {
BooleanGene gene = new BooleanGene(conf);
gene.setAllele(Boolean.valueOf(false));
String s = gene.getPersistentRepresentation();
assertEquals("false", s);
}
/**
* @throws Exception
*
* @author Klaus Meffert
*/
public void testGetPersistentRepresentation_2()
throws Exception {
BooleanGene gene = new BooleanGene(conf);
String s = gene.getPersistentRepresentation();
assertEquals("null", s);
}
/**
* @throws Exception
*
* @author Klaus Meffert
* @since 2.2
*/
public void testHashCode_0()
throws Exception {
BooleanGene gene = new BooleanGene(conf);
assertEquals( -2, gene.hashCode());
}
/**
* @throws Exception
*
* @author Klaus Meffert
* @since 2.4
*/
public void testSetEnergy_0()
throws Exception {
BaseGene gene = new BooleanGene(conf);
assertEquals(0.0, gene.getEnergy(), DELTA);
}
/**
* @throws Exception
*
* @author Klaus Meffert
* @since 2.4
*/
public void testSetEnergy_1()
throws Exception {
BaseGene gene = new BooleanGene(conf);
gene.setEnergy(2.3);
assertEquals(2.3, gene.getEnergy(), DELTA);
gene.setEnergy( -55.8);
assertEquals( -55.8, gene.getEnergy(), DELTA);
gene.setEnergy(0.5);
gene.setEnergy(0.8);
assertEquals(0.8, gene.getEnergy(), DELTA);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -