2006-02-10 22:11:12 +03:00
|
|
|
MACRO(TEST command expected)
|
|
|
|
IF("x${result}" STREQUAL "x${expected}")
|
2006-05-15 18:14:16 +04:00
|
|
|
#MESSAGE("TEST \"${command}\" success: \"${result}\" expected: \"${expected}\"")
|
2006-02-10 22:11:12 +03:00
|
|
|
ELSE("x${result}" STREQUAL "x${expected}")
|
2006-05-15 17:57:49 +04:00
|
|
|
MESSAGE(SEND_ERROR "${CMAKE_CURRENT_LIST_LINE}: TEST \"${command}\" failed: \"${result}\" expected: \"${expected}\"")
|
2006-02-10 22:11:12 +03:00
|
|
|
ENDIF("x${result}" STREQUAL "x${expected}")
|
|
|
|
ENDMACRO(TEST command expected)
|
|
|
|
|
|
|
|
SET(mylist andy bill ken brad)
|
|
|
|
|
|
|
|
LIST(LENGTH mylist result)
|
|
|
|
TEST("LENGTH mylist result" "4")
|
|
|
|
LIST(LENGTH "mylist" result)
|
|
|
|
TEST("LENGTH \"mylist\" result" "4")
|
|
|
|
|
2006-05-15 17:25:06 +04:00
|
|
|
LIST(LENGTH "nonexiting_list1" result)
|
|
|
|
TEST("LENGTH \"nonexiting_list1\" result" "0")
|
|
|
|
|
2006-02-10 22:11:12 +03:00
|
|
|
LIST(GET mylist 3 2 1 0 result)
|
|
|
|
TEST("GET mylist 3 2 1 0 result" "brad;ken;bill;andy")
|
|
|
|
|
|
|
|
LIST(GET mylist 0 item0)
|
|
|
|
LIST(GET mylist 1 item1)
|
|
|
|
LIST(GET mylist 2 item2)
|
|
|
|
LIST(GET mylist 3 item3)
|
|
|
|
SET(result "${item3}" "${item0}" "${item1}" "${item2}")
|
|
|
|
TEST("GET individual 3 2 1 0 result" "brad;andy;bill;ken")
|
|
|
|
|
|
|
|
LIST(GET mylist -1 -2 -3 -4 result)
|
|
|
|
TEST("GET mylist -1 -2 -3 -4 result" "brad;ken;bill;andy")
|
|
|
|
|
|
|
|
LIST(GET mylist -1 2 -3 0 result)
|
|
|
|
TEST("GET mylist -1 2 -3 0 ${result}" "brad;ken;bill;andy")
|
|
|
|
|
2006-05-15 17:25:06 +04:00
|
|
|
LIST(GET "nonexiting_list2" 1 result)
|
|
|
|
TEST("GET \"nonexiting_list2\" 1 result" "NOTFOUND")
|
|
|
|
|
2006-02-10 22:11:12 +03:00
|
|
|
SET(result andy)
|
2006-05-15 17:25:06 +04:00
|
|
|
LIST(APPEND result brad)
|
|
|
|
TEST("APPEND result brad" "andy;brad")
|
|
|
|
|
|
|
|
LIST(APPEND "nonexiting_list3" brad)
|
|
|
|
SET(result "${nonexiting_list3}")
|
2006-05-15 18:14:16 +04:00
|
|
|
TEST("APPEND \"nonexiting_list3\" brad" "brad")
|
|
|
|
|
|
|
|
LIST(INSERT "nonexiting_list4" 0 andy bill brad ken)
|
|
|
|
SET(result "${nonexiting_list4}")
|
|
|
|
TEST("APPEND \"nonexiting_list4\" andy bill brad ken" "andy;bill;brad;ken")
|
2006-02-10 22:11:12 +03:00
|
|
|
|
|
|
|
SET(result andy brad)
|
|
|
|
LIST(INSERT result -1 bill ken)
|
|
|
|
TEST("INSERT result -1 bill ken" "andy;bill;ken;brad")
|
|
|
|
|
|
|
|
SET(result andy bill brad ken bob)
|
2006-05-15 17:57:49 +04:00
|
|
|
LIST(REMOVE_ITEM result bob)
|
|
|
|
TEST("REMOVE_ITEM result bob" "andy;bill;brad;ken")
|
2006-02-10 22:11:12 +03:00
|
|
|
|
|
|
|
SET(result andy bill bob brad ken peter)
|
2006-05-15 17:57:49 +04:00
|
|
|
LIST(REMOVE_ITEM result peter bob)
|
|
|
|
TEST("REMOVE_ITEM result peter bob" "andy;bill;brad;ken")
|
|
|
|
|
|
|
|
SET(result bob andy bill bob brad ken bob)
|
|
|
|
LIST(REMOVE_ITEM result bob)
|
|
|
|
TEST("REMOVE_ITEM result bob" "andy;bill;brad;ken")
|
2006-02-10 22:11:12 +03:00
|
|
|
|
|
|
|
SET(result andy bill bob brad ken peter)
|
2006-05-15 17:57:49 +04:00
|
|
|
LIST(REMOVE_AT result 2 -1)
|
|
|
|
TEST("REMOVE_AT result 2 -1" "andy;bill;brad;ken")
|
2007-07-12 19:56:45 +04:00
|
|
|
|
2007-08-15 18:26:50 +04:00
|
|
|
# ken is at index 2, nobody is not in the list so -1 should be returned
|
|
|
|
SET(mylist andy bill ken brad)
|
|
|
|
LIST(FIND mylist ken result)
|
|
|
|
TEST("FIND mylist ken result" "2")
|
2007-07-12 19:56:45 +04:00
|
|
|
|
2007-08-15 18:26:50 +04:00
|
|
|
LIST(FIND mylist nobody result)
|
|
|
|
TEST("FIND mylist nobody result" "-1")
|
2007-07-12 19:56:45 +04:00
|
|
|
|
|
|
|
SET(result ken bill andy brad)
|
|
|
|
LIST(SORT result)
|
|
|
|
TEST("SORT result" "andy;bill;brad;ken")
|
|
|
|
|
|
|
|
SET(result andy bill brad ken)
|
|
|
|
LIST(REVERSE result)
|
|
|
|
TEST("REVERSE result" "ken;brad;bill;andy")
|
2008-03-13 00:02:10 +03:00
|
|
|
|
|
|
|
SET(result bill andy bill brad ken ken ken)
|
|
|
|
LIST(REMOVE_DUPLICATES result)
|
|
|
|
TEST("REMOVE_DUPLICATES result" "bill;andy;brad;ken")
|