summaryrefslogtreecommitdiffstats
path: root/Tests/Complex
diff options
context:
space:
mode:
authorSebastien Barre <sebastien.barre@kitware.com>2002-01-19 01:32:06 (GMT)
committerSebastien Barre <sebastien.barre@kitware.com>2002-01-19 01:32:06 (GMT)
commitc26008ccf3999156cab5a05172a04c562bed9cc8 (patch)
treeee95576b1664de2b2dbc8d97be121dc168292b9f /Tests/Complex
parent2b5bb96e2367e28e980d4dcc3ddbcbebe34d08af (diff)
downloadCMake-c26008ccf3999156cab5a05172a04c562bed9cc8.zip
CMake-c26008ccf3999156cab5a05172a04c562bed9cc8.tar.gz
CMake-c26008ccf3999156cab5a05172a04c562bed9cc8.tar.bz2
ENH: Increase test + coverage
Diffstat (limited to 'Tests/Complex')
-rw-r--r--Tests/Complex/CMakeLists.txt24
-rw-r--r--Tests/Complex/Executable/CMakeLists.txt8
-rw-r--r--Tests/Complex/Executable/complex.cxx40
-rw-r--r--Tests/Complex/VarTests.cmake (renamed from Tests/Complex/VarTests.txt)24
4 files changed, 85 insertions, 11 deletions
diff --git a/Tests/Complex/CMakeLists.txt b/Tests/Complex/CMakeLists.txt
index 050cd3e..cae0377 100644
--- a/Tests/Complex/CMakeLists.txt
+++ b/Tests/Complex/CMakeLists.txt
@@ -12,7 +12,9 @@ ENDIF (CMAKE_ANSI_CXXFLAGS)
ADD_DEFINITIONS(-DCMAKE_IS_FUN)
-INCLUDE(${Complex_SOURCE_DIR}/VarTests.txt)
+IF (EXISTS ${Complex_SOURCE_DIR}/VarTests.cmake)
+ INCLUDE(${Complex_SOURCE_DIR}/VarTests.cmake)
+ENDIF (EXISTS ${Complex_SOURCE_DIR}/VarTests.cmake)
LOAD_CACHE(${Complex_SOURCE_DIR})
@@ -53,13 +55,18 @@ SUBDIRS(Library Executable)
SUBDIR_DEPENDS(Executable Library)
#
-# Exec program
+# Exec program (TODO: test a result)
# Increase coverage.
#
-OPTION(EXEC_PROGRAM "Test EXEC_PROGRAM" ON)
-IF (EXEC_PROGRAM)
- EXEC_PROGRAM("echo EXEC_PROGRAM")
-ENDIF (EXEC_PROGRAM)
+OPTION(NO_EXEC_PROGRAM "Do not test EXEC_PROGRAM" 0)
+IF (NOT NO_EXEC_PROGRAM)
+ EXEC_PROGRAM("echo NO_EXEC_PROGRAM" "${Complex_BINARY_DIR}")
+ELSE (NOT NO_EXEC_PROGRAM)
+ MESSAGE("Set this option ON")
+ENDIF (NOT NO_EXEC_PROGRAM)
+
+MARK_AS_ADVANCED(NO_EXEC_PROGRAM)
+MARK_AS_ADVANCED(CLEAR NO_EXEC_PROGRAM)
#
# More coverage
@@ -78,6 +85,11 @@ INSTALL_FILES(/tmp .h ${Complex_BINARY_DIR}/cmTestConfigure.h)
MAKE_DIRECTORY("${Complex_BINARY_DIR}/make_dir")
#
+# Testing
+#
+ENABLE_TESTING()
+
+#
# Test Cable
#
CABLE_CLASS_SET(Float float)
diff --git a/Tests/Complex/Executable/CMakeLists.txt b/Tests/Complex/Executable/CMakeLists.txt
index 4bd1620..15808b4 100644
--- a/Tests/Complex/Executable/CMakeLists.txt
+++ b/Tests/Complex/Executable/CMakeLists.txt
@@ -14,7 +14,13 @@ FIND_LIBRARY(CMAKE_LIB
TARGET_LINK_LIBRARIES(complex ${CMAKE_LIB})
LINK_LIBRARIES(${CMAKE_LIB})
-# More coverage
+#
+# Testing
+#
+ADD_TEST(complex ${Complex_BINARY_DIR}/bin/complex)
+#
+# More coverage
+#
INSTALL_TARGETS(/tmp complex)
INSTALL_PROGRAMS(/tmp complex)
diff --git a/Tests/Complex/Executable/complex.cxx b/Tests/Complex/Executable/complex.cxx
index b2f5162..6a55b5c 100644
--- a/Tests/Complex/Executable/complex.cxx
+++ b/Tests/Complex/Executable/complex.cxx
@@ -106,6 +106,42 @@ int main()
Passed("SHOULD_BE_DEFINED is defined.");
#endif
+#ifdef SHOULD_NOT_BE_DEFINED_AND
+ Failed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_AND is defined.");
+#else
+ Passed("SHOULD_NOT_BE_DEFINED_AND is not defined.");
+#endif
+
+#ifndef SHOULD_BE_DEFINED_AND
+ Failed("IF or SET is broken, SHOULD_BE_DEFINED_AND is not defined.\n");
+#else
+ Passed("SHOULD_BE_DEFINED_AND is defined.");
+#endif
+
+#ifdef SHOULD_NOT_BE_DEFINED_OR
+ Failed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_OR is defined.");
+#else
+ Passed("SHOULD_NOT_BE_DEFINED_OR is not defined.");
+#endif
+
+#ifndef SHOULD_BE_DEFINED_OR
+ Failed("IF or SET is broken, SHOULD_BE_DEFINED_OR is not defined.\n");
+#else
+ Passed("SHOULD_BE_DEFINED_OR is defined.");
+#endif
+
+#ifdef SHOULD_NOT_BE_DEFINED_MATCHES
+ Failed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_MATCHES is defined.");
+#else
+ Passed("SHOULD_NOT_BE_DEFINED_MATCHES is not defined.");
+#endif
+
+#ifndef SHOULD_BE_DEFINED_MATCHES
+ Failed("IF or SET is broken, SHOULD_BE_DEFINED_MATCHES is not defined.\n");
+#else
+ Passed("SHOULD_BE_DEFINED_MATCHES is defined.");
+#endif
+
#ifndef ONE_VAR
Failed("cmakedefine is broken, ONE_VAR is not defined.");
#else
@@ -188,7 +224,7 @@ int main()
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
"FILENAME_VAR_NAME is not defined.");
#else
- if(strcmp(FILENAME_VAR_NAME, "VarTests.txt") != 0)
+ if(strcmp(FILENAME_VAR_NAME, "VarTests.cmake") != 0)
{
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
"FILENAME_VAR_NAME == ", FILENAME_VAR_NAME);
@@ -203,7 +239,7 @@ int main()
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
"FILENAME_VAR_EXT is not defined.");
#else
- if(strcmp(FILENAME_VAR_EXT, ".txt") != 0)
+ if(strcmp(FILENAME_VAR_EXT, ".cmake") != 0)
{
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
"FILENAME_VAR_EXT == ", FILENAME_VAR_EXT);
diff --git a/Tests/Complex/VarTests.txt b/Tests/Complex/VarTests.cmake
index 0775636..ee3faf3 100644
--- a/Tests/Complex/VarTests.txt
+++ b/Tests/Complex/VarTests.cmake
@@ -11,13 +11,33 @@ SET(ONE_VAR 1)
VARIABLE_REQUIRES(ONE_VAR
ONE_VAR_IS_DEFINED ONE_VAR)
+SET (ONE_VAR2 1)
+
+IF(ONE_VAR AND ONE_VAR2)
+ ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_AND)
+ELSE(ONE_VAR AND ONE_VAR2)
+ ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_AND)
+ENDIF(ONE_VAR AND ONE_VAR2)
+
+IF(ZERO_VAR OR ONE_VAR2)
+ ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_OR)
+ELSE(ZERO_VAR OR ONE_VAR2)
+ ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_OR)
+ENDIF(ZERO_VAR OR ONE_VAR2)
+
SET(STRING_VAR "CMake is great" CACHE STRING "test a cache variable")
+IF(STRING_VAR MATCHES "^CMake")
+ ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_MATCHES)
+ELSE(STRING_VAR MATCHES "^CMake")
+ ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_MATCHES)
+ENDIF(STRING_VAR MATCHES "^CMake")
+
FOREACH (INDEX 1 2)
SET(FOREACH_VAR${INDEX} "VALUE${INDEX}")
ENDFOREACH(INDEX)
-FIND_FILE(FILENAME_VAR "VarTests.txt" ${Complex_SOURCE_DIR})
+FIND_FILE(FILENAME_VAR "VarTests.cmake" ${Complex_SOURCE_DIR})
GET_FILENAME_COMPONENT(FILENAME_VAR_PATH ${FILENAME_VAR} PATH)
GET_FILENAME_COMPONENT(FILENAME_VAR_PATH_NAME ${FILENAME_VAR_PATH} NAME)
@@ -25,7 +45,7 @@ GET_FILENAME_COMPONENT(FILENAME_VAR_NAME ${FILENAME_VAR} NAME)
GET_FILENAME_COMPONENT(FILENAME_VAR_EXT ${FILENAME_VAR} EXT)
GET_FILENAME_COMPONENT(FILENAME_VAR_NAME_WE ${FILENAME_VAR} NAME_WE)
-FIND_PATH(PATH_VAR "VarTests.txt" ${Complex_SOURCE_DIR})
+FIND_PATH(PATH_VAR "VarTests.cmake" ${Complex_SOURCE_DIR})
GET_FILENAME_COMPONENT(PATH_VAR_NAME ${PATH_VAR} NAME)
# Coverage only