aboutsummaryrefslogtreecommitdiffstats
path: root/src/jcgp/tests/InputTests.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/jcgp/tests/InputTests.java')
-rw-r--r--src/jcgp/tests/InputTests.java47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/jcgp/tests/InputTests.java b/src/jcgp/tests/InputTests.java
new file mode 100644
index 0000000..3803990
--- /dev/null
+++ b/src/jcgp/tests/InputTests.java
@@ -0,0 +1,47 @@
+package jcgp.tests;
+
+import static org.junit.Assert.assertTrue;
+import jcgp.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. TODO this value should be generically typed.
+ * - 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.", 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);
+ }
+
+}