math: Add RunCMake.math test to prepare for error cases

This commit is contained in:
Daniel Franke 2018-05-18 21:59:46 +02:00 committed by Brad King
parent 575f97763f
commit 963b8d9f6c
4 changed files with 16 additions and 0 deletions

View File

@ -238,6 +238,7 @@ add_RunCMake_test(include)
add_RunCMake_test(include_directories)
add_RunCMake_test(include_guard)
add_RunCMake_test(list)
add_RunCMake_test(math)
add_RunCMake_test(message)
add_RunCMake_test(project -DCMake_TEST_RESOURCES=${CMake_TEST_RESOURCES})
add_RunCMake_test(return)

View File

@ -0,0 +1,3 @@
cmake_minimum_required(VERSION 2.8.4)
project(${RunCMake_TEST} NONE)
include(${RunCMake_TEST}.cmake)

View File

@ -0,0 +1,9 @@
macro(math_test expression expected)
math(EXPR evaluated ${expression} ${ARGN})
if (NOT evaluated STREQUAL ${expected})
message(FATAL_ERROR "wrong math result: ${evaluated} != ${expected}")
endif ()
endmacro()
math_test("100 * 10" 1000)

View File

@ -0,0 +1,3 @@
include(RunCMake)
run_cmake(MATH)