diff options
author | Andy Cedilnik <andy.cedilnik@kitware.com> | 2005-06-16 18:56:28 (GMT) |
---|---|---|
committer | Andy Cedilnik <andy.cedilnik@kitware.com> | 2005-06-16 18:56:28 (GMT) |
commit | c34696021d5fe72bed2b45ee52b37076a1d14dae (patch) | |
tree | ac85eb85e19227607e38abf09b3ecaafa87c6831 | |
parent | 9a7dec33a37f475c89a2d24f3b19c5b16fb876f8 (diff) | |
download | CMake-c34696021d5fe72bed2b45ee52b37076a1d14dae.zip CMake-c34696021d5fe72bed2b45ee52b37076a1d14dae.tar.gz CMake-c34696021d5fe72bed2b45ee52b37076a1d14dae.tar.bz2 |
ENH: Add test of macro
-rw-r--r-- | Source/CMakeLists.txt | 10 | ||||
-rw-r--r-- | Tests/MacroTest/CMakeLists.txt | 48 | ||||
-rw-r--r-- | Tests/MacroTest/macroTest.c | 7 |
3 files changed, 65 insertions, 0 deletions
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 87813ee..91f3009 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -400,6 +400,16 @@ IF(BUILD_TESTING) --build-two-config --test-command conly) + ADD_TEST(MacroTest ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/MacroTest" + "${CMake_BINARY_DIR}/Tests/MacroTest" + --build-generator ${CMAKE_GENERATOR} + --build-project littleMacroTest + --build-makeprogram ${MAKEPROGRAM} + --build-two-config + --test-command miniMacroTest) + SET(SimpleInstallInstallDir "${CMake_BINARY_DIR}/Tests/SimpleInstall/InstallDirectory") ADD_TEST(SimpleInstall ${CMAKE_CTEST_COMMAND} diff --git a/Tests/MacroTest/CMakeLists.txt b/Tests/MacroTest/CMakeLists.txt new file mode 100644 index 0000000..98fcbaf --- /dev/null +++ b/Tests/MacroTest/CMakeLists.txt @@ -0,0 +1,48 @@ +# a simple C only test case +PROJECT (littleMacroTest C) + +MACRO(FAILED testname) + MESSAGE(SEND_ERROR "${testname} failed ${ARGN}") +ENDMACRO(FAILED) + +MACRO(PASS testname) + MESSAGE("${testname} passed ${ARGN}") +ENDMACRO(PASS) + +# test ARGC +MACRO(weird_name) + IF("${ARGC}" EQUAL "3") + PASS("ARGC") + ELSE("${ARGC}" EQUAL "3") + FAILED("ARGC" "Got: ${ARGC}") + ENDIF("${ARGC}" EQUAL "3") +ENDMACRO(weird_name) +WeIrD_nAmE(a1 a2 a3) + +# test ARGN +MACRO(test_argn_macro argument) + IF("${ARGN}" EQUAL "3") + PASS("ARGN") + ELSE("${ARGN}" EQUAL "3") + FAILED("ARGN" "Got: ${ARGN}") + ENDIF("${ARGN}" EQUAL "3") +ENDMACRO(test_argn_macro) +Test_Argn_Macro(ignored 3) + +# case test +MACRO(strange_macro m) + SET("${m}" strange_macro) +ENDMACRO(strange_macro m) +STRANGE_MACRO(var) +set(second_var "second_var") +IF("${var}" EQUAL "strange_macro" AND "${second_var}" EQUAL "second_var") + PASS("Case Test" "(${var} ${second_var})") +ELSE("${var}" EQUAL "strange_macro" AND "${second_var}" EQUAL "second_var") + FAILED("Case test" "(${var} ${second_var})") +ENDIF("${var}" EQUAL "strange_macro" AND "${second_var}" EQUAL "second_var") + +# test backing up command +MACRO(ADD_EXECUTABLE exec) + _ADD_EXECUTABLE("mini${exec}" ${ARGN}) +ENDMACRO(ADD_EXECUTABLE) +ADD_EXECUTABLE(MacroTest macroTest.c) diff --git a/Tests/MacroTest/macroTest.c b/Tests/MacroTest/macroTest.c new file mode 100644 index 0000000..e0ced6a --- /dev/null +++ b/Tests/MacroTest/macroTest.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +int main(int argc, char* argv[]) +{ + printf("Running command: %s with %d arguments\n", argv[0], argc); + return 0; +} |