ENH: added tests for the CMAKE_MATCH_(0..9) variables, which get set by

regex matches (STRING(REGEX), IF(MATCHES))

Alex
This commit is contained in:
Alexander Neundorf 2007-08-29 12:01:58 -04:00
parent e80acd971c
commit ef13337c1f
1 changed files with 33 additions and 0 deletions

View File

@ -56,6 +56,39 @@ STRING(TOUPPER "CMake" tuvar)
STRING(TOLOWER "CMake" tlvar) STRING(TOLOWER "CMake" tlvar)
STRING(REPLACE "Autoconf" "CMake" repvar "People should use Autoconf") STRING(REPLACE "Autoconf" "CMake" repvar "People should use Autoconf")
IF("abc" STREQUAL "xyz")
MESSAGE(SEND_ERROR "Problem with the IF(STREQUAL), \"abc\" and \"xyz\" considered equal")
ENDIF("abc" STREQUAL "xyz")
IF("CMake is cool" MATCHES "(CMake) (is).+")
IF(NOT "${CMAKE_MATCH_0}" STREQUAL "CMake is cool")
MESSAGE(SEND_ERROR "CMAKE_MATCH_0 wrong: \"${CMAKE_MATCH_0}\", expected \"CMake is cool\"")
ENDIF(NOT "${CMAKE_MATCH_0}" STREQUAL "CMake is cool")
IF(NOT "${CMAKE_MATCH_1}" STREQUAL "CMake")
MESSAGE(SEND_ERROR "CMAKE_MATCH_1 wrong: \"${CMAKE_MATCH_1}\", expected \"CMake\"")
ENDIF(NOT "${CMAKE_MATCH_1}" STREQUAL "CMake")
IF(NOT "${CMAKE_MATCH_2}" STREQUAL "is")
MESSAGE(SEND_ERROR "CMAKE_MATCH_2 wrong: \"${CMAKE_MATCH_2}\", expected \"is\"")
ENDIF(NOT "${CMAKE_MATCH_2}" STREQUAL "is")
ELSE("CMake is cool" MATCHES "(CMake) (is).+")
MESSAGE(SEND_ERROR "Problem with the IF(MATCHES), no match found")
ENDIF("CMake is cool" MATCHES "(CMake) (is).+")
STRING(REGEX MATCH "(People).+CMake" matchResultVar "People should use CMake")
IF(NOT "${matchResultVar}" STREQUAL "People should use CMake")
MESSAGE(SEND_ERROR "STRING(REGEX MATCH) problem: \"${matchResultVar}\", expected \"People should use CMake\"")
ENDIF(NOT "${matchResultVar}" STREQUAL "People should use CMake")
IF(NOT "${CMAKE_MATCH_0}" STREQUAL "People should use CMake")
MESSAGE(SEND_ERROR "CMAKE_MATCH_0 wrong: \"${CMAKE_MATCH_0}\", expected \"People should use CMake\"")
ENDIF(NOT "${CMAKE_MATCH_0}" STREQUAL "People should use CMake")
IF(NOT "${CMAKE_MATCH_1}" STREQUAL "People")
MESSAGE(SEND_ERROR "CMAKE_MATCH_1 wrong: \"${CMAKE_MATCH_1}\", expected \"People\"")
ENDIF(NOT "${CMAKE_MATCH_1}" STREQUAL "People")
IF(NOT "${CMAKE_MATCH_2}" STREQUAL "")
MESSAGE(SEND_ERROR "CMAKE_MATCH_2 wrong: \"${CMAKE_MATCH_2}\", expected empty string")
ENDIF(NOT "${CMAKE_MATCH_2}" STREQUAL "")
STRING(STRIP " STRING(STRIP "
ST1 ST1
" ST1) " ST1)