From df05a5e73a23a09c4db32237067dbd8176d8d1e0 Mon Sep 17 00:00:00 2001
From: Stephane Del Pino <stephane.delpino44@gmail.com>
Date: Mon, 28 May 2018 18:05:36 +0200
Subject: [PATCH] improve unit tests management

---
 tests/CMakeLists.txt        | 11 +++++++----
 tests/example.cpp           | 19 -------------------
 tests/example2.cpp          | 19 -------------------
 tests/main.cpp              |  9 ---------
 tests/test_RevisionInfo.cpp |  7 +++++++
 tests/test_TinyVector.cpp   |  8 ++++++++
 tests/test_main.cpp         |  2 ++
 7 files changed, 24 insertions(+), 51 deletions(-)
 delete mode 100644 tests/example.cpp
 delete mode 100644 tests/example2.cpp
 delete mode 100644 tests/main.cpp
 create mode 100644 tests/test_RevisionInfo.cpp
 create mode 100644 tests/test_TinyVector.cpp
 create mode 100644 tests/test_main.cpp

diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index e1573d44d..21ba01a73 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -2,12 +2,15 @@ include_directories("${CATCH_INCLUDE_PATH}")
 
 set(EXECUTABLE_OUTPUT_PATH ${PASTIS_BINARY_DIR})
 add_executable (unit_tests
-  main.cpp
-  example.cpp
-  example2.cpp)
+  test_main.cpp
+  test_RevisionInfo.cpp
+  test_TinyVector.cpp)
 
 target_include_directories(Catch INTERFACE ${CATCH_INCLUDE_DIR})
-target_link_libraries (unit_tests Catch)
+target_link_libraries (
+  unit_tests
+  PastisUtils
+  Catch)
 
 enable_testing()
 
diff --git a/tests/example.cpp b/tests/example.cpp
deleted file mode 100644
index 0cbc903b5..000000000
--- a/tests/example.cpp
+++ /dev/null
@@ -1,19 +0,0 @@
-#include <catch.hpp>
-
-TEST_CASE("Test1", "[unit]") {
-    int a = 1;
-    int b = 2;
-    REQUIRE(a == b);
-}
-
-TEST_CASE("Test2") {
-    int a = 2;
-    int b = 2;
-    REQUIRE(a == b);
-}
-
-TEST_CASE("Test3", "[a][b][c]") {
-    int a = 1;
-    int b = 2;
-    REQUIRE(a != b);
-}
diff --git a/tests/example2.cpp b/tests/example2.cpp
deleted file mode 100644
index 076fa5840..000000000
--- a/tests/example2.cpp
+++ /dev/null
@@ -1,19 +0,0 @@
-#include <catch.hpp>
-
-TEST_CASE("Test5", "[unit]") {
-    int a = 1;
-    int b = 2;
-    REQUIRE(a+1 == b);
-}
-
-TEST_CASE("Test6", "[a]") {
-    int a = 2;
-    int b = 2;
-    REQUIRE(a == b);
-}
-
-TEST_CASE("Test7", "[a][b][c]") {
-    int a = 1;
-    int b = 2;
-    REQUIRE(a != b);
-}
diff --git a/tests/main.cpp b/tests/main.cpp
deleted file mode 100644
index 7253fe66f..000000000
--- a/tests/main.cpp
+++ /dev/null
@@ -1,9 +0,0 @@
-#define CATCH_CONFIG_MAIN
-#include <catch.hpp>
-// #define CATCH_CONFIG_RUNNER
-// #include <catch.hpp>
-
-// int main(int argc, char* argv[]) {
-//   auto result = Catch::Session().run(argc, argv);
-//   return (result < 0xff ? result : 0xff);
-// }
diff --git a/tests/test_RevisionInfo.cpp b/tests/test_RevisionInfo.cpp
new file mode 100644
index 000000000..9359c8cb3
--- /dev/null
+++ b/tests/test_RevisionInfo.cpp
@@ -0,0 +1,7 @@
+#include <catch.hpp>
+
+#include <RevisionInfo.hpp>
+
+TEST_CASE("RevisionInfo", "[utils]") {
+  REQUIRE(RevisionInfo::hasGitInfo() == true);
+}
diff --git a/tests/test_TinyVector.cpp b/tests/test_TinyVector.cpp
new file mode 100644
index 000000000..5e29a8e5d
--- /dev/null
+++ b/tests/test_TinyVector.cpp
@@ -0,0 +1,8 @@
+#include <catch.hpp>
+
+#include <TinyVector.hpp>
+
+TEST_CASE("TinyVector", "[algebra]") {
+  TinyVector<3,int> v(1,2,3);
+  REQUIRE(((v[0] == 1) and (v[1] == 2) and (v[2] == 3)));
+}
diff --git a/tests/test_main.cpp b/tests/test_main.cpp
new file mode 100644
index 000000000..b3143fbb1
--- /dev/null
+++ b/tests/test_main.cpp
@@ -0,0 +1,2 @@
+#define CATCH_CONFIG_MAIN
+#include <catch.hpp>
-- 
GitLab