浏览代码

Work towards testing framework. CxxTest.

enhancement_3
Trevor Irons 8 年前
父节点
当前提交
5f22a0c59a

+ 21
- 4
CMakeLists.txt 查看文件

@@ -158,7 +158,7 @@ if(COMPILER_SUPPORTS_OPENMP AND LEMMA_USE_OPENMP )
158 158
 endif()
159 159
 
160 160
 set(LEMMA_VERSION_MAJOR "0")
161
-set(LEMMA_VERSION_MINOR "0")
161
+set(LEMMA_VERSION_MINOR "1")
162 162
 set(LEMMA_VERSION_PATCH "1")
163 163
 set(LEMMA_VERSION "${LEMMA_VERSION_MAJOR}.${LEMMA_VERSION_MINOR}.${LEMMA_VERSION_PATCH}")
164 164
 
@@ -172,6 +172,23 @@ include_directories ("${PROJECT_SOURCE_DIR}/LemmaCore/include")
172 172
 include_directories ("${CMAKE_INSTALL_PREFIX}/include/eigen3")
173 173
 include_directories ("${CMAKE_INSTALL_PREFIX}/include/")
174 174
 link_directories ("${CMAKE_INSTALL_PREFIX}/lib/")
175
+
176
+option (LEMMA_ENABLE_TESTING  "Turn on unit testing" ON)
177
+if (LEMMA_ENABLE_TESTING)
178
+find_package(CxxTest REQUIRED)
179
+if(CXXTEST_FOUND)
180
+    include_directories(${CXXTEST_INCLUDE_DIR})
181
+    enable_testing()
182
+    #CXXTEST_ADD_TEST(tester_executable runner.cpp
183
+    #                    ${CMAKE_CURRENT_SOURCE_DIR}/src/myTestsuite.h)
184
+	CXXTEST_ADD_TEST(unittest_foo foo_test.cc
185
+                      ${CMAKE_CURRENT_SOURCE_DIR}/src/myTestSuite.h)
186
+    #target_link_libraries(unittest_foo foo) # as needed
187
+	else()
188
+	message(FATAL_ERROR "CxxTest not found.")
189
+	endif()
190
+endif()
191
+
175 192
 add_subdirectory (LemmaCore) 
176 193
 
177 194
 ########################################################################
@@ -182,9 +199,9 @@ add_subdirectory (Modules)
182 199
 # 
183 200
 include_directories(${CMAKE_INSTALL_PREFIX}/include)
184 201
 
185
-#add_executable(Hello "${PROJECT_SOURCE_DIR}/src/test.cpp")
186
-#target_link_libraries(Hello lemmacore)
187
-#add_dependencies(Hello YAML-CPP)
202
+add_executable(Hello "${PROJECT_SOURCE_DIR}/src/test.cpp")
203
+target_link_libraries(Hello lemmacore)
204
+add_dependencies(Hello YAML-CPP)
188 205
 
189 206
 
190 207
 # add a target to generate API documentation with Doxygen

+ 5
- 0
LemmaCore/CMakeLists.txt 查看文件

@@ -33,6 +33,11 @@ endif()
33 33
 
34 34
 target_link_libraries(lemmacore "yaml-cpp")
35 35
 
36
+# Testing
37
+if (LEMMA_ENABLE_TESTING)
38
+	add_subdirectory(testing)
39
+endif()
40
+
36 41
 # Install
37 42
 install ( TARGETS lemmacore DESTINATION ${CMAKE_INSTALL_PREFIX}/lib )
38 43
 

+ 0
- 3
LemmaCore/examples/CMakeLists.txt 查看文件

@@ -31,6 +31,3 @@ add_executable( filter  filter.cpp )
31 31
 target_link_libraries(filter "lemmacore")
32 32
 
33 33
 
34
-
35
-
36
-

+ 4
- 0
LemmaCore/testing/CMakeLists.txt 查看文件

@@ -0,0 +1,4 @@
1
+add_executable(testOne testOne.cpp)
2
+add_executable(testTwo testTwo.cpp)
3
+add_test( testLemmaCoreOne testOne )
4
+add_test( testLemmaCoreTwo testTwo )

+ 23
- 0
LemmaCore/testing/testOne.cpp 查看文件

@@ -0,0 +1,23 @@
1
+/* This file is part of Lemma, a geophysical modelling and inversion API.
2
+ * More information is available at http://lemmasoftware.org
3
+ */
4
+
5
+/* This Source Code Form is subject to the terms of the Mozilla Public
6
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
7
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8
+ */
9
+
10
+/**
11
+ * @file
12
+ * @date      06/14/2016 09:30:38 PM
13
+ * @version   $Id$
14
+ * @author    Trevor Irons (ti)
15
+ * @email     tirons@egi.utah.edu
16
+ * @copyright Copyright (c) 2016, University of Utah
17
+ * @copyright Copyright (c) 2016, Trevor Irons & Lemma Software, LLC
18
+ */
19
+
20
+int main() {
21
+    return 0;
22
+}
23
+

+ 23
- 0
LemmaCore/testing/testTwo.cpp 查看文件

@@ -0,0 +1,23 @@
1
+/* This file is part of Lemma, a geophysical modelling and inversion API.
2
+ * More information is available at http://lemmasoftware.org
3
+ */
4
+
5
+/* This Source Code Form is subject to the terms of the Mozilla Public
6
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
7
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8
+ */
9
+
10
+/**
11
+ * @file
12
+ * @date      06/14/2016 09:43:43 PM
13
+ * @version   $Id$
14
+ * @author    Trevor Irons (ti)
15
+ * @email     tirons@egi.utah.edu
16
+ * @copyright Copyright (c) 2016, University of Utah
17
+ * @copyright Copyright (c) 2016, Trevor Irons & Lemma Software, LLC
18
+ */
19
+
20
+int main() {
21
+    return 0;
22
+}
23
+

+ 32
- 0
src/myTestSuite.h 查看文件

@@ -0,0 +1,32 @@
1
+/* This file is part of Lemma, a geophysical modelling and inversion API.
2
+ * More information is available at http://lemmasoftware.org
3
+ */
4
+
5
+/* This Source Code Form is subject to the terms of the Mozilla Public
6
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
7
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8
+ */
9
+
10
+/**
11
+ * @file
12
+ * @date      06/14/2016 10:06:34 PM
13
+ * @version   $Id$
14
+ * @author    Trevor Irons (ti)
15
+ * @email     tirons@egi.utah.edu
16
+ * @copyright Copyright (c) 2016, University of Utah
17
+ * @copyright Copyright (c) 2016, Trevor Irons & Lemma Software, LLC
18
+ */
19
+
20
+          // MyTestSuite.h
21
+          #include <cxxtest/TestSuite.h>
22
+
23
+          class MyTestSuite : public CxxTest::TestSuite
24
+          {
25
+          public:
26
+             void testAddition( void )
27
+             {
28
+                TS_ASSERT( 1 + 1 > 1 );
29
+                TS_ASSERT_EQUALS( 1 + 1, 2 );
30
+             }
31
+          };
32
+

+ 0
- 26
src/test.cpp 查看文件

@@ -20,36 +20,10 @@
20 20
 #include <iostream>
21 21
 #include "LemmaConfig.h"
22 22
 #include "lemma.h"
23
-#include "dipolesource.h"
24 23
 
25 24
 using namespace Lemma;
26 25
 
27 26
 int main() {
28 27
     std::cout << "Hello Lemma " << LEMMA_VERSION_MAJOR << "\t" << LEMMA_VERSION_MINOR << std::endl;
29
-//    std::cout << "thingy()\t" << thingy() << std::endl;
30
-
31
-    // Test with a single dipole
32
-    DipoleSource *dipole = DipoleSource::New();
33
-        dipole->SetType(GROUNDEDELECTRICDIPOLE);
34
-            //dipole->SetPolarisation(1., 0.0,  1.0);
35
-        //    dipole->SetPolarisation(XPOLARISATION);
36
-        dipole->SetPolarisation(YPOLARISATION);
37
-        //dipole->SetPolarisation(ZPOLARISATION);
38
-
39
-        /////////////
40
-        //dipole->SetType(MAGNETICDIPOLE);
41
-            //dipole->SetPolarisation(0., 0.0,  1.0);
42
-            //dipole->SetPolarisation(XPOLARISATION);
43
-        //dipole->SetPolarisation(YPOLARISATION);
44
-        //dipole->SetPolarisation(ZPOLARISATION);
45
-
46
-        //dipole->SetMoment(1);
47
-        //dipole->SetLocation(1,1,-.0100328);
48
-        dipole->SetLocation(0., 0., -0.001);
49
-        //dipole->SetLocation(-2.5,1.25,0);
50
-        dipole->SetNumberOfFrequencies(1);
51
-        dipole->SetFrequency(0, 2e7);
52
-
53
-    std::cout << *dipole << std::endl;
54 28
 }
55 29
 

正在加载...
取消
保存