diff options
author | Andy Cedilnik <andy.cedilnik@kitware.com> | 2006-02-10 19:11:12 (GMT) |
---|---|---|
committer | Andy Cedilnik <andy.cedilnik@kitware.com> | 2006-02-10 19:11:12 (GMT) |
commit | f87271d0eae52e6c670d10b53e72eed72e80bfd1 (patch) | |
tree | f5c7c2c35fd68be706db491c96422d545f409031 /Tests | |
parent | b8a33fb424aa28b710e0ec170814ac380ee057db (diff) | |
download | CMake-f87271d0eae52e6c670d10b53e72eed72e80bfd1.zip CMake-f87271d0eae52e6c670d10b53e72eed72e80bfd1.tar.gz CMake-f87271d0eae52e6c670d10b53e72eed72e80bfd1.tar.bz2 |
ENH: Add initial implementation of the list command
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/CMakeTests/CMakeLists.txt | 10 | ||||
-rw-r--r-- | Tests/CMakeTests/ListTest.cmake.in | 50 |
2 files changed, 60 insertions, 0 deletions
diff --git a/Tests/CMakeTests/CMakeLists.txt b/Tests/CMakeTests/CMakeLists.txt new file mode 100644 index 0000000..a1eefb5 --- /dev/null +++ b/Tests/CMakeTests/CMakeLists.txt @@ -0,0 +1,10 @@ +SET(CMAKE_EXECUTABLE "${EXECUTABLE_OUTPUT_PATH}/cmake") + + +MACRO(AddCMakeTest TestName Arguments) + CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/${TestName}Test.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/${TestName}Test.cmake" @ONLY IMMEDIATE) + ADD_TEST(CMake.List ${CMAKE_EXECUTABLE} -P "${CMAKE_CURRENT_BINARY_DIR}/ListTest.cmake" ${Arguments}) +ENDMACRO(AddCMakeTest) + +AddCMakeTest(List "") diff --git a/Tests/CMakeTests/ListTest.cmake.in b/Tests/CMakeTests/ListTest.cmake.in new file mode 100644 index 0000000..48b157c --- /dev/null +++ b/Tests/CMakeTests/ListTest.cmake.in @@ -0,0 +1,50 @@ +MACRO(TEST command expected) + IF("x${result}" STREQUAL "x${expected}") + MESSAGE("TEST \"${command}\" success: \"${result}\" expected: \"${expected}\"") + ELSE("x${result}" STREQUAL "x${expected}") + MESSAGE(SEND_ERROR "TEST \"${command}\" failed: \"${result}\" expected: \"${expected}\"") + ENDIF("x${result}" STREQUAL "x${expected}") +ENDMACRO(TEST command expected) + +SET(mylist andy bill ken brad) + +LIST(LENGTH mylist result) +TEST("LENGTH mylist result" "4") +LIST(LENGTH "mylist" result) +TEST("LENGTH \"mylist\" result" "4") + +LIST(GET mylist 3 2 1 0 result) +TEST("GET mylist 3 2 1 0 result" "brad;ken;bill;andy") + +LIST(GET mylist 0 item0) +LIST(GET mylist 1 item1) +LIST(GET mylist 2 item2) +LIST(GET mylist 3 item3) +SET(result "${item3}" "${item0}" "${item1}" "${item2}") +TEST("GET individual 3 2 1 0 result" "brad;andy;bill;ken") + +LIST(GET mylist -1 -2 -3 -4 result) +TEST("GET mylist -1 -2 -3 -4 result" "brad;ken;bill;andy") + +LIST(GET mylist -1 2 -3 0 result) +TEST("GET mylist -1 2 -3 0 ${result}" "brad;ken;bill;andy") + +SET(result andy) +LIST(SET result brad) +TEST("SET result brad" "andy;brad") + +SET(result andy brad) +LIST(INSERT result -1 bill ken) +TEST("INSERT result -1 bill ken" "andy;bill;ken;brad") + +SET(result andy bill brad ken bob) +LIST(REMOVE result bob) +TEST("REMOVE result bob" "andy;bill;brad;ken") + +SET(result andy bill bob brad ken peter) +LIST(REMOVE result peter bob) +TEST("REMOVE result peter bob" "andy;bill;brad;ken") + +SET(result andy bill bob brad ken peter) +LIST(REMOVE_ITEM result 2 -1) +TEST("REMOVE_ITEM result 2 -1" "andy;bill;brad;ken") |