test_utils.cmake 961 B

123456789101112131415161718192021222324252627282930
  1. function(TEST variable)
  2. if(ARGC GREATER 2)
  3. set(i 0)
  4. foreach(value IN LISTS ${variable})
  5. math(EXPR j "${i} + 1")
  6. set(${variable}[${i}] "${value}")
  7. TEST(${variable}[${i}] "${ARGV${j}}")
  8. set(i ${j})
  9. endforeach()
  10. else()
  11. set(expected "${ARGN}")
  12. if("${expected}" STREQUAL "UNDEFINED")
  13. if(DEFINED ${variable})
  14. message(FATAL_ERROR "'${variable}' shall be undefined but has value '${${variable}}'")
  15. endif()
  16. elseif("${expected}" STREQUAL "FALSE")
  17. if(NOT ${variable} STREQUAL "FALSE")
  18. message(FATAL_ERROR "'${variable}' shall be FALSE")
  19. endif()
  20. elseif("${expected}" STREQUAL "TRUE")
  21. if(NOT ${variable} STREQUAL "TRUE")
  22. message(FATAL_ERROR "'${variable}' shall be TRUE")
  23. endif()
  24. else()
  25. if(NOT ${variable} STREQUAL "${expected}")
  26. message(FATAL_ERROR "'${variable}' shall be '${expected}'")
  27. endif()
  28. endif()
  29. endif()
  30. endfunction()