summaryrefslogtreecommitdiffstats
path: root/Tests/MathTest/CMakeLists.txt
diff options
context:
space:
mode:
authorDaniel Franke <franke@edf-online.de>2018-05-18 19:59:46 (GMT)
committerBrad King <brad.king@kitware.com>2018-07-03 13:55:58 (GMT)
commit5dbee9d2d0f68e1fc343d04ac00a4a35d43df6fa (patch)
tree85375da2fabdfbc7982fe4ba58a76acc3167c71e /Tests/MathTest/CMakeLists.txt
parent8661e7052c4f711f13e7168231276e23c4c0defd (diff)
downloadCMake-5dbee9d2d0f68e1fc343d04ac00a4a35d43df6fa.zip
CMake-5dbee9d2d0f68e1fc343d04ac00a4a35d43df6fa.tar.gz
CMake-5dbee9d2d0f68e1fc343d04ac00a4a35d43df6fa.tar.bz2
math: Add options to calculate and format output as hexadecimal
Diffstat (limited to 'Tests/MathTest/CMakeLists.txt')
-rw-r--r--Tests/MathTest/CMakeLists.txt33
1 files changed, 27 insertions, 6 deletions
diff --git a/Tests/MathTest/CMakeLists.txt b/Tests/MathTest/CMakeLists.txt
index f764b3a..5403d29 100644
--- a/Tests/MathTest/CMakeLists.txt
+++ b/Tests/MathTest/CMakeLists.txt
@@ -13,14 +13,35 @@ set(expressions
"-1 + +1"
"+1 - -1"
"+1 - - + + -(-3 + - - +1)"
+ "1000 -12*5"
+ "1000 +12*-5"
+ "1000 -12*-5"
)
-set(FILE_EXPRESSIONS "")
-foreach(expression
- ${expressions})
- math(EXPR expr "${expression}")
- string(APPEND FILE_EXPRESSIONS "TEST_EXPRESSION(${expression}, ${expr})\n")
-endforeach()
+set(FILE_EXPRESSIONS "extern void test_expression(int x, int y, const char * text);\n")
+
+
+macro(add_math_test expression)
+ math(EXPR result ${expression} ${ARGV1} ${ARGV2})
+ set(CODE "test_expression(${expression}, ${result}, \"${expression}\");")
+ string(APPEND FILE_EXPRESSIONS "${CODE}\n")
+endmacro()
+
+macro(add_math_tests)
+ foreach (expression ${expressions})
+ add_math_test(${expression} ${ARGV0} ${ARGV1})
+ endforeach ()
+endmacro()
+
+add_math_tests()
+add_math_tests("OUTPUT_FORMAT" "DECIMAL")
+add_math_tests("OUTPUT_FORMAT" "HEXADECIMAL")
+
+# Avoid the test with negative result and hexadecimal formatting
+# therefore more tests with a negative result
+add_math_test("-12*5")
+add_math_test("12*-5")
+
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/MathTestTests.h.in"