blob: 4f628e8b97aee3277cbc8ea6f4fcb8df759b3c0e [file]
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)
math_test("100 * 10" 1000 OUTPUT_FORMAT DECIMAL)
math_test("100 * 0xA" 1000 OUTPUT_FORMAT DECIMAL)
math_test("100 * 0xA" 0x3e8 OUTPUT_FORMAT HEXADECIMAL)
function(inc_dec_test command initial_value expected)
set(value "${initial_value}")
math("${command}" value)
if(NOT value STREQUAL "${expected}")
message(FATAL_ERROR "wrong ${command} result: ${value} != ${expected}")
endif()
endfunction()
inc_dec_test(INCREMENT 0 1)
inc_dec_test(INCREMENT 4 5)
inc_dec_test(INCREMENT -04 -3)
inc_dec_test(INCREMENT -9223372036854775808 -9223372036854775807)
inc_dec_test(DECREMENT 0 -1)
inc_dec_test(DECREMENT 4 3)
inc_dec_test(DECREMENT -04 -5)
inc_dec_test(DECREMENT 9223372036854775807 9223372036854775806)