Skip to content

Commit 10bb6be

Browse files
author
jeanyves-yang
committed
ENH: tests on input file and output file with several radii added.
1 parent 6615c3c commit 10bb6be

File tree

7 files changed

+597
-0
lines changed

7 files changed

+597
-0
lines changed

Exercices/MedianFilter/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,11 @@ SEMMacroBuildCLI(
1919
TARGET_LIBRARIES ${ITK_LIBRARIES}
2020
)
2121

22+
option(BUILD_TESTING "Build the testing tree" ON)
23+
24+
IF(BUILD_TESTING)
25+
include(CTest)
26+
ADD_SUBDIRECTORY(Testing)
27+
ENDIF(BUILD_TESTING)
28+
29+
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
set(Data Data)
2+
3+
set(TEMP_DIR ${MedianFilter_BINARY_DIR}/Testing/Temporary )
4+
set(SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/${Data} )
5+
6+
set(BaselineRadius2 ${SOURCE_DIR}/baselineT2Radius2.nrrd )
7+
set(BaselineRadius4 ${SOURCE_DIR}/baselineT2Radius4.nrrd )
8+
set(DummyOutput ${SOURCE_DIR}/DummyOutput.nrrd )
9+
set(Input ${SOURCE_DIR}/inputT2.nrrd )
10+
include_directories( ${CMAKE_SOURCE_DIR} )
11+
add_executable(MedianFilterTest MedianFilterTest.cxx)
12+
target_link_libraries(MedianFilterTest MedianFilterLib)
13+
set( RadiusValue2 ${TEMP_DIR}/RadiusValue2.nrrd )
14+
set( RadiusValue4 ${TEMP_DIR}/RadiusValue4.nrrd )
15+
16+
# Test checking that the program cannot run without arguments
17+
add_test(NAME OpenFileTest COMMAND $<TARGET_FILE:MedianFilter>)
18+
set_tests_properties(OpenFileTest PROPERTIES WILL_FAIL true )
19+
20+
# Test checking that the radius value cannot go below 1
21+
add_test(NAME RadiusLimitMin COMMAND $<TARGET_FILE:MedianFilter>
22+
${Input}
23+
${DummyOutput}
24+
-r 0
25+
)
26+
set_tests_properties( RadiusLimitMin PROPERTIES WILL_FAIL true )
27+
28+
#Test checking that a wrong input will prevent the program from running
29+
add_test(NAME MedianFilterWrongInputFileName COMMAND $<TARGET_FILE:MedianFilter>
30+
WrongInput.nrrd
31+
${DummyOutput}
32+
-r 20
33+
)
34+
set_tests_properties( MedianFilterWrongInputFileName PROPERTIES WILL_FAIL true )
35+
36+
# Tests checking that that the output image is what is expected
37+
add_test(NAME MedianFilterRadiusValue2 COMMAND $<TARGET_FILE:MedianFilterTest>
38+
--compare
39+
${BaselineRadius2}
40+
${RadiusValue2}
41+
ModuleEntryPoint
42+
${Input}
43+
${RadiusValue2}
44+
-r 2
45+
)
46+
47+
add_test(NAME MedianFilterRadiusValue4 COMMAND $<TARGET_FILE:MedianFilterTest>
48+
--compare
49+
${BaselineRadius4}
50+
${RadiusValue4}
51+
ModuleEntryPoint
52+
${Input}
53+
${RadiusValue4}
54+
-r 4
55+
)
56+
57+
# Test for the command --help
58+
add_test(NAME PrintHelp COMMAND $<TARGET_FILE:MedianFilter> --help)
Binary file not shown.
Binary file not shown.
Binary file not shown.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include "itkTestMain.h"
2+
3+
#ifdef WIN32
4+
#define MODULE_IMPORT __declspec(dllimport)
5+
#else
6+
#define MODULE_IMPORT
7+
#endif
8+
9+
extern "C" MODULE_IMPORT int ModuleEntryPoint(int, char * []);
10+
11+
void RegisterTests()
12+
{
13+
StringToTestFunctionMap["ModuleEntryPoint"] = ModuleEntryPoint;
14+
}

0 commit comments

Comments
 (0)