diff options
Diffstat (limited to 'src/jcgp/backend/tests/InputTests.java')
-rw-r--r-- | src/jcgp/backend/tests/InputTests.java | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/jcgp/backend/tests/InputTests.java b/src/jcgp/backend/tests/InputTests.java new file mode 100644 index 0000000..4d15667 --- /dev/null +++ b/src/jcgp/backend/tests/InputTests.java @@ -0,0 +1,47 @@ +package jcgp.backend.tests; + +import static org.junit.Assert.assertTrue; +import jcgp.backend.population.Input; + +import org.junit.Before; +import org.junit.Test; + +/** + * + * Tests which cover the behaviour specified for an input. + * + * - An input contains a single set value. This value can be freely set for + * fitness evaluation purposes. + * - It must be addressable by an index set upon construction only. + * + * + * @author Eduardo Pedroni + * + */ +public class InputTests { + + private Input input; + // these are the test values + private final int inputValue = 19; + private final int inputIndex = 12; + + @Before + public void setUp() throws Exception { + input = new Input(inputIndex); + } + + @Test + public void valueTest() { + // assign a value to input, check that the returned value is correct + input.setValue(inputValue); + + assertTrue("Incorrect value returned.", ((Integer) input.getValue()) == inputValue); + } + + @Test + public void indexTest() { + // check that the index returned is the one passed to the constructor + assertTrue("Incorrect index returned.", input.getIndex() == inputIndex); + } + +} |