ListTest.cmake.in 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. MACRO(TEST command expected)
  2. IF("x${result}" STREQUAL "x${expected}")
  3. #MESSAGE("TEST \"${command}\" success: \"${result}\" expected: \"${expected}\"")
  4. ELSE("x${result}" STREQUAL "x${expected}")
  5. MESSAGE(SEND_ERROR "${CMAKE_CURRENT_LIST_LINE}: TEST \"${command}\" failed: \"${result}\" expected: \"${expected}\"")
  6. ENDIF("x${result}" STREQUAL "x${expected}")
  7. ENDMACRO(TEST command expected)
  8. SET(mylist andy bill ken brad)
  9. LIST(LENGTH mylist result)
  10. TEST("LENGTH mylist result" "4")
  11. LIST(LENGTH "mylist" result)
  12. TEST("LENGTH \"mylist\" result" "4")
  13. LIST(LENGTH "nonexiting_list1" result)
  14. TEST("LENGTH \"nonexiting_list1\" result" "0")
  15. LIST(GET mylist 3 2 1 0 result)
  16. TEST("GET mylist 3 2 1 0 result" "brad;ken;bill;andy")
  17. LIST(GET mylist 0 item0)
  18. LIST(GET mylist 1 item1)
  19. LIST(GET mylist 2 item2)
  20. LIST(GET mylist 3 item3)
  21. SET(result "${item3}" "${item0}" "${item1}" "${item2}")
  22. TEST("GET individual 3 2 1 0 result" "brad;andy;bill;ken")
  23. LIST(GET mylist -1 -2 -3 -4 result)
  24. TEST("GET mylist -1 -2 -3 -4 result" "brad;ken;bill;andy")
  25. LIST(GET mylist -1 2 -3 0 result)
  26. TEST("GET mylist -1 2 -3 0 ${result}" "brad;ken;bill;andy")
  27. LIST(GET "nonexiting_list2" 1 result)
  28. TEST("GET \"nonexiting_list2\" 1 result" "NOTFOUND")
  29. SET(result andy)
  30. LIST(APPEND result brad)
  31. TEST("APPEND result brad" "andy;brad")
  32. LIST(APPEND "nonexiting_list3" brad)
  33. SET(result "${nonexiting_list3}")
  34. TEST("APPEND \"nonexiting_list3\" brad" "brad")
  35. LIST(INSERT "nonexiting_list4" 0 andy bill brad ken)
  36. SET(result "${nonexiting_list4}")
  37. TEST("APPEND \"nonexiting_list4\" andy bill brad ken" "andy;bill;brad;ken")
  38. SET(result andy brad)
  39. LIST(INSERT result -1 bill ken)
  40. TEST("INSERT result -1 bill ken" "andy;bill;ken;brad")
  41. SET(result andy bill brad ken bob)
  42. LIST(REMOVE_ITEM result bob)
  43. TEST("REMOVE_ITEM result bob" "andy;bill;brad;ken")
  44. SET(result andy bill bob brad ken peter)
  45. LIST(REMOVE_ITEM result peter bob)
  46. TEST("REMOVE_ITEM result peter bob" "andy;bill;brad;ken")
  47. SET(result bob andy bill bob brad ken bob)
  48. LIST(REMOVE_ITEM result bob)
  49. TEST("REMOVE_ITEM result bob" "andy;bill;brad;ken")
  50. SET(result andy bill bob brad ken peter)
  51. LIST(REMOVE_AT result 2 -1)
  52. TEST("REMOVE_AT result 2 -1" "andy;bill;brad;ken")