diff options
Diffstat (limited to 'src/jcgp/backend/tests')
-rw-r--r-- | src/jcgp/backend/tests/ChromosomeTests.java | 6 | ||||
-rw-r--r-- | src/jcgp/backend/tests/NodeTests.java | 32 | ||||
-rw-r--r-- | src/jcgp/backend/tests/OutputTests.java | 2 | ||||
-rw-r--r-- | src/jcgp/backend/tests/PopulationTests.java | 2 |
4 files changed, 32 insertions, 10 deletions
diff --git a/src/jcgp/backend/tests/ChromosomeTests.java b/src/jcgp/backend/tests/ChromosomeTests.java index 1cd067e..a16ba75 100644 --- a/src/jcgp/backend/tests/ChromosomeTests.java +++ b/src/jcgp/backend/tests/ChromosomeTests.java @@ -2,13 +2,13 @@ package jcgp.backend.tests; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; -import jcgp.JCGP.Resources; import jcgp.backend.population.Chromosome; import jcgp.backend.population.Connection; import jcgp.backend.population.Input; import jcgp.backend.population.MutableElement; import jcgp.backend.population.Node; import jcgp.backend.population.Output; +import jcgp.backend.resources.ModifiableResources; import org.junit.Before; import org.junit.BeforeClass; @@ -40,11 +40,11 @@ import org.junit.Test; public class ChromosomeTests { private Chromosome chromosome; - private static Resources resources; + private static ModifiableResources resources; @BeforeClass public static void setUpBeforeClass() { - resources = new Resources(); + resources = new ModifiableResources(); } @Before diff --git a/src/jcgp/backend/tests/NodeTests.java b/src/jcgp/backend/tests/NodeTests.java index 7121e81..2294816 100644 --- a/src/jcgp/backend/tests/NodeTests.java +++ b/src/jcgp/backend/tests/NodeTests.java @@ -1,12 +1,13 @@ package jcgp.backend.tests; import static org.junit.Assert.assertTrue; -import jcgp.JCGP.Resources; -import jcgp.backend.function.Arithmetic; +import jcgp.backend.exceptions.InvalidArgumentsException; import jcgp.backend.function.Function; +import jcgp.backend.function.IntegerArithmetic; import jcgp.backend.population.Chromosome; import jcgp.backend.population.Connection; import jcgp.backend.population.Node; +import jcgp.backend.resources.Resources; import org.junit.Before; import org.junit.BeforeClass; @@ -48,7 +49,7 @@ public class NodeTests { public void setUp() throws Exception { node = new Node(chromosome, 0, 0, resources.getInt("arity")); // make node with anonymous addition function and hard-coded value connections - node.initialise(new Arithmetic.Addition(), + node.initialise(new IntegerArithmetic.Addition(), new Connection[]{new Connection() { @Override @@ -126,7 +127,7 @@ public class NodeTests { ((int) node.getValue()) == arg1 + arg2); // put in a different function, check the output has changed appropriately - node.setFunction(new Arithmetic.Subtraction()); + node.setFunction(new IntegerArithmetic.Subtraction()); assertTrue("Node did not return expected value (difference of arguments).", ((Integer) node.getValue()) == arg1 - arg2); @@ -166,7 +167,28 @@ public class NodeTests { } }; - node.initialise(null, conn0, conn1); + + Function function = new Function() { + @Override + public Object run(Connection... connections) + throws InvalidArgumentsException { + // blank + return null; + } + + @Override + public int getArity() { + return 2; + } + + @Override + public String getName() { + // blank + return null; + } + }; + + node.initialise(function, conn0, conn1); assertTrue("Connection 0 is incorrect.", node.getConnection(0) == conn0); assertTrue("Connection 1 is incorrect.", node.getConnection(1) == conn1); diff --git a/src/jcgp/backend/tests/OutputTests.java b/src/jcgp/backend/tests/OutputTests.java index 7ff8a4a..b2bc7ec 100644 --- a/src/jcgp/backend/tests/OutputTests.java +++ b/src/jcgp/backend/tests/OutputTests.java @@ -1,10 +1,10 @@ package jcgp.backend.tests; import static org.junit.Assert.assertTrue; -import jcgp.JCGP.Resources; import jcgp.backend.population.Chromosome; import jcgp.backend.population.Connection; import jcgp.backend.population.Output; +import jcgp.backend.resources.Resources; import org.junit.Before; import org.junit.BeforeClass; diff --git a/src/jcgp/backend/tests/PopulationTests.java b/src/jcgp/backend/tests/PopulationTests.java index 51b5168..31df8b9 100644 --- a/src/jcgp/backend/tests/PopulationTests.java +++ b/src/jcgp/backend/tests/PopulationTests.java @@ -1,9 +1,9 @@ package jcgp.backend.tests; import static org.junit.Assert.assertTrue; -import jcgp.JCGP.Resources; import jcgp.backend.population.Chromosome; import jcgp.backend.population.Population; +import jcgp.backend.resources.Resources; import org.junit.Before; import org.junit.BeforeClass; |