2012-08-13 21:47:32 +04:00
|
|
|
macro(TEST command expected)
|
|
|
|
if("x${result}" STREQUAL "x${expected}")
|
|
|
|
#message("TEST \"${command}\" success: \"${result}\" expected: \"${expected}\"")
|
2012-08-13 21:50:14 +04:00
|
|
|
else()
|
2012-08-13 21:47:32 +04:00
|
|
|
message(SEND_ERROR "${CMAKE_CURRENT_LIST_LINE}: TEST \"${command}\" failed: \"${result}\" expected: \"${expected}\"")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
|
|
|
endmacro()
|
2006-02-10 22:11:12 +03:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
set(mylist andy bill ken brad)
|
2006-02-10 22:11:12 +03:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
list(LENGTH mylist result)
|
2006-02-10 22:11:12 +03:00
|
|
|
TEST("LENGTH mylist result" "4")
|
2012-08-13 21:47:32 +04:00
|
|
|
list(LENGTH "mylist" result)
|
2006-02-10 22:11:12 +03:00
|
|
|
TEST("LENGTH \"mylist\" result" "4")
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
list(LENGTH "nonexiting_list1" result)
|
2006-05-15 17:25:06 +04:00
|
|
|
TEST("LENGTH \"nonexiting_list1\" result" "0")
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
list(GET mylist 3 2 1 0 result)
|
2006-02-10 22:11:12 +03:00
|
|
|
TEST("GET mylist 3 2 1 0 result" "brad;ken;bill;andy")
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
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}")
|
2006-02-10 22:11:12 +03:00
|
|
|
TEST("GET individual 3 2 1 0 result" "brad;andy;bill;ken")
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
list(GET mylist -1 -2 -3 -4 result)
|
2006-02-10 22:11:12 +03:00
|
|
|
TEST("GET mylist -1 -2 -3 -4 result" "brad;ken;bill;andy")
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
list(GET mylist -1 2 -3 0 result)
|
2006-02-10 22:11:12 +03:00
|
|
|
TEST("GET mylist -1 2 -3 0 ${result}" "brad;ken;bill;andy")
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
list(GET "nonexiting_list2" 1 result)
|
2006-05-15 17:25:06 +04:00
|
|
|
TEST("GET \"nonexiting_list2\" 1 result" "NOTFOUND")
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
set(result andy)
|
|
|
|
list(APPEND result brad)
|
2006-05-15 17:25:06 +04:00
|
|
|
TEST("APPEND result brad" "andy;brad")
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
list(APPEND "nonexiting_list3" brad)
|
|
|
|
set(result "${nonexiting_list3}")
|
2006-05-15 18:14:16 +04:00
|
|
|
TEST("APPEND \"nonexiting_list3\" brad" "brad")
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
list(INSERT "nonexiting_list4" 0 andy bill brad ken)
|
|
|
|
set(result "${nonexiting_list4}")
|
2006-05-15 18:14:16 +04:00
|
|
|
TEST("APPEND \"nonexiting_list4\" andy bill brad ken" "andy;bill;brad;ken")
|
2006-02-10 22:11:12 +03:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
set(result andy brad)
|
|
|
|
list(INSERT result -1 bill ken)
|
2006-02-10 22:11:12 +03:00
|
|
|
TEST("INSERT result -1 bill ken" "andy;bill;ken;brad")
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
set(result andy bill brad ken bob)
|
|
|
|
list(REMOVE_ITEM result bob)
|
2006-05-15 17:57:49 +04:00
|
|
|
TEST("REMOVE_ITEM result bob" "andy;bill;brad;ken")
|
2006-02-10 22:11:12 +03:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
set(result andy bill bob brad ken peter)
|
|
|
|
list(REMOVE_ITEM result peter bob)
|
2006-05-15 17:57:49 +04:00
|
|
|
TEST("REMOVE_ITEM result peter bob" "andy;bill;brad;ken")
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
set(result bob andy bill bob brad ken bob)
|
|
|
|
list(REMOVE_ITEM result bob)
|
2006-05-15 17:57:49 +04:00
|
|
|
TEST("REMOVE_ITEM result bob" "andy;bill;brad;ken")
|
2006-02-10 22:11:12 +03:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
set(result andy bill bob brad ken peter)
|
|
|
|
list(REMOVE_AT result 2 -1)
|
2006-05-15 17:57:49 +04:00
|
|
|
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
|
2012-08-13 21:47:32 +04:00
|
|
|
set(mylist andy bill ken brad)
|
|
|
|
list(FIND mylist ken result)
|
2007-08-15 18:26:50 +04:00
|
|
|
TEST("FIND mylist ken result" "2")
|
2007-07-12 19:56:45 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
list(FIND mylist nobody result)
|
2007-08-15 18:26:50 +04:00
|
|
|
TEST("FIND mylist nobody result" "-1")
|
2007-07-12 19:56:45 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
set(result ken bill andy brad)
|
|
|
|
list(SORT result)
|
2007-07-12 19:56:45 +04:00
|
|
|
TEST("SORT result" "andy;bill;brad;ken")
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
set(result andy bill brad ken)
|
|
|
|
list(REVERSE result)
|
2007-07-12 19:56:45 +04:00
|
|
|
TEST("REVERSE result" "ken;brad;bill;andy")
|
2008-03-13 00:02:10 +03:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
set(result bill andy bill brad ken ken ken)
|
|
|
|
list(REMOVE_DUPLICATES result)
|
2008-03-13 00:02:10 +03:00
|
|
|
TEST("REMOVE_DUPLICATES result" "bill;andy;brad;ken")
|