CMakeLists.txt 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. cmake_minimum_required (VERSION 2.6)
  2. project(MathTest)
  3. # Expression test
  4. set(expressions
  5. "5 * ( 3 + 4)"
  6. "(1 | 2 | 4 | 8) & 16"
  7. "1 +(3*4) + 10 >> 2"
  8. "10000 / 20 / 4"
  9. "10000 / (20 / 4)"
  10. "-1 + +1"
  11. "+1 - -1"
  12. "+1 - - + + -(-3 + - - +1)"
  13. "1000 -12*5"
  14. "1000 +12*-5"
  15. "1000 -12*-5"
  16. )
  17. set(FILE_EXPRESSIONS "extern void test_expression(int x, int y, const char * text);\n")
  18. macro(add_math_test expression)
  19. math(EXPR result ${expression} ${ARGV1} ${ARGV2})
  20. set(CODE "test_expression(${expression}, ${result}, \"${expression}\");")
  21. string(APPEND FILE_EXPRESSIONS "${CODE}\n")
  22. endmacro()
  23. macro(add_math_tests)
  24. foreach (expression ${expressions})
  25. add_math_test(${expression} ${ARGV0} ${ARGV1})
  26. endforeach ()
  27. endmacro()
  28. add_math_tests()
  29. add_math_tests("OUTPUT_FORMAT" "DECIMAL")
  30. add_math_tests("OUTPUT_FORMAT" "HEXADECIMAL")
  31. # Avoid the test with negative result and hexadecimal formatting
  32. # therefore more tests with a negative result
  33. add_math_test("-12*5")
  34. add_math_test("12*-5")
  35. configure_file(
  36. "${CMAKE_CURRENT_SOURCE_DIR}/MathTestTests.h.in"
  37. "${CMAKE_CURRENT_BINARY_DIR}/MathTestTests.h"
  38. @ONLY)
  39. include_directories("${CMAKE_CURRENT_BINARY_DIR}")
  40. add_executable(MathTest MathTestExec.cxx)