Add tests.
authorRafał Długołęcki <rafal@dlugolecki.net.pl>
Tue, 7 Apr 2015 23:32:02 +0000 (01:32 +0200)
committerRafał Długołęcki <rafal@dlugolecki.net.pl>
Tue, 7 Apr 2015 23:32:02 +0000 (01:32 +0200)
Makefile.am
autogen.sh
configure.ac
tests/Makefile.am [new file with mode: 0644]
tests/gene/Makefile.am [new file with mode: 0644]
tests/gene/copy.cpp [new file with mode: 0644]
tests/gene/create.cpp [new file with mode: 0644]
tests/gene/test1.cpp [deleted file]

index c54316149ee7fadccb162c40ed26313dfd07fa70..77706d61da6f08dfc00e657467e94c441664c551 100644 (file)
@@ -24,6 +24,8 @@ CLEANFILES = \
     %~ \
     doxyfile.stamp
 
+SUBDIRS = . tests
+
 bin_PROGRAMS = bin/genetic
 dist_noinst_SCRIPTS = autogen.sh
 
index fcd4df547c2cd4ecef323a5da777d54e59f5280a..bfb874eea9d66cccd97e7a42002ab229c0fa21e4 100755 (executable)
@@ -1,3 +1,4 @@
 #! /bin/sh
 
 autoreconf --force --install
+automake --add-missing
\ No newline at end of file
index 04d60ccf1f47693f39b972c2189580b2f287dcdf..25a8fedc43ae60d9e071281cdf6189143565d541 100644 (file)
@@ -4,7 +4,11 @@ AC_PREREQ([2.59])
 AM_INIT_AUTOMAKE([1.10 -Wall])
 AC_CONFIG_HEADERS([config.h])
 AC_PROG_CXX
-AC_CONFIG_FILES([Makefile])
+AC_CONFIG_FILES([
+    Makefile
+    tests/Makefile
+    tests/gene/Makefile
+])
 
 AC_OUTPUT
 
diff --git a/tests/Makefile.am b/tests/Makefile.am
new file mode 100644 (file)
index 0000000..417b211
--- /dev/null
@@ -0,0 +1,4 @@
+SUBDIRS = gene
+
+clean-local:
+       rm -f *.log
\ No newline at end of file
diff --git a/tests/gene/Makefile.am b/tests/gene/Makefile.am
new file mode 100644 (file)
index 0000000..85ec6e8
--- /dev/null
@@ -0,0 +1,16 @@
+noinst_PROGRAMS  = create.test copy.test
+
+create_test_SOURCES  = create.cpp
+create_test_CPPFLAGS = -I$(top_srcdir)/src
+
+copy_test_SOURCES  = copy.cpp
+copy_test_CPPFLAGS = -I$(top_srcdir)/src
+
+TESTS = \
+    create.test \
+    copy.test
+
+check-gene:    create.test copy.test  all
+
+clean-local:
+       rm -f *.test
\ No newline at end of file
diff --git a/tests/gene/copy.cpp b/tests/gene/copy.cpp
new file mode 100644 (file)
index 0000000..554fa12
--- /dev/null
@@ -0,0 +1,24 @@
+#include <iostream>
+
+#include "gene.h"
+
+using namespace std;
+using namespace genetic;
+
+int main() {
+    typedef Gene<int> _Gene;
+
+    _Gene gene(1);
+    _Gene gene2(20);
+
+    gene = gene2;
+
+    if (gene.get() != 20) {
+        cout << "Gene does not copied value\n";
+    }
+
+    cout << "Gene copied value from second gene\n";
+
+    return 0;
+}
+
diff --git a/tests/gene/create.cpp b/tests/gene/create.cpp
new file mode 100644 (file)
index 0000000..9bc970e
--- /dev/null
@@ -0,0 +1,21 @@
+#include <iostream>
+
+#include "gene.h"
+
+using namespace std;
+using namespace genetic;
+
+int main() {
+    typedef Gene<int> _Gene;
+
+    _Gene gene(1);
+
+    if (gene.get() != 1) {
+        cout << "Gene does not contained initial value\n";
+        return 1;
+    }
+
+    cout << "Gene contained initial value\n";
+    return 0;
+}
+
diff --git a/tests/gene/test1.cpp b/tests/gene/test1.cpp
deleted file mode 100644 (file)
index eed1e94..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-#include <iostream>
-#include <cassert>
-
-#include "gene.h"
-#include "chromosome.h"
-
-using namespace std;
-using namespace genetic;
-
-int main() {
-    Gene<int> gene(1);
-
-    assert(gene.get() == 1);
-    cout << "Gene: " << gene.get() << " should be equal to: " << 1 << endl;
-
-    return 0;
-}
-