From ef13337c1f4fb7d02b89f54780c50f99d81643a0 Mon Sep 17 00:00:00 2001 From: Alexander Neundorf Date: Wed, 29 Aug 2007 12:01:58 -0400 Subject: ENH: added tests for the CMAKE_MATCH_(0..9) variables, which get set by regex matches (STRING(REGEX), IF(MATCHES)) Alex --- Tests/StringFileTest/CMakeLists.txt | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/Tests/StringFileTest/CMakeLists.txt b/Tests/StringFileTest/CMakeLists.txt index 36d15ce..9768947 100644 --- a/Tests/StringFileTest/CMakeLists.txt +++ b/Tests/StringFileTest/CMakeLists.txt @@ -56,6 +56,39 @@ STRING(TOUPPER "CMake" tuvar) STRING(TOLOWER "CMake" tlvar) 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 " ST1 " ST1) -- cgit v0.12