ListTest.cmake.in 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 "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(GET mylist 3 2 1 0 result)
  14. TEST("GET mylist 3 2 1 0 result" "brad;ken;bill;andy")
  15. LIST(GET mylist 0 item0)
  16. LIST(GET mylist 1 item1)
  17. LIST(GET mylist 2 item2)
  18. LIST(GET mylist 3 item3)
  19. SET(result "${item3}" "${item0}" "${item1}" "${item2}")
  20. TEST("GET individual 3 2 1 0 result" "brad;andy;bill;ken")
  21. LIST(GET mylist -1 -2 -3 -4 result)
  22. TEST("GET mylist -1 -2 -3 -4 result" "brad;ken;bill;andy")
  23. LIST(GET mylist -1 2 -3 0 result)
  24. TEST("GET mylist -1 2 -3 0 ${result}" "brad;ken;bill;andy")
  25. SET(result andy)
  26. LIST(SET result brad)
  27. TEST("SET result brad" "andy;brad")
  28. SET(result andy brad)
  29. LIST(INSERT result -1 bill ken)
  30. TEST("INSERT result -1 bill ken" "andy;bill;ken;brad")
  31. SET(result andy bill brad ken bob)
  32. LIST(REMOVE result bob)
  33. TEST("REMOVE result bob" "andy;bill;brad;ken")
  34. SET(result andy bill bob brad ken peter)
  35. LIST(REMOVE result peter bob)
  36. TEST("REMOVE result peter bob" "andy;bill;brad;ken")
  37. SET(result andy bill bob brad ken peter)
  38. LIST(REMOVE_ITEM result 2 -1)
  39. TEST("REMOVE_ITEM result 2 -1" "andy;bill;brad;ken")