Introduce "generator expressions" to add_test()
[cmake.git] / Tests / CMakeTests / ListTest.cmake.in
blobcf6f91a70e0f49aa12180ffe3a58115ae5aec175
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)
9 SET(mylist andy bill ken brad)
11 LIST(LENGTH mylist result)
12 TEST("LENGTH mylist result" "4")
13 LIST(LENGTH "mylist" result)
14 TEST("LENGTH \"mylist\" result" "4")
16 LIST(LENGTH "nonexiting_list1" result)
17 TEST("LENGTH \"nonexiting_list1\" result" "0")
19 LIST(GET mylist 3 2 1 0 result)
20 TEST("GET mylist 3 2 1 0 result" "brad;ken;bill;andy")
22 LIST(GET mylist 0 item0)
23 LIST(GET mylist 1 item1)
24 LIST(GET mylist 2 item2)
25 LIST(GET mylist 3 item3)
26 SET(result "${item3}" "${item0}" "${item1}" "${item2}")
27 TEST("GET individual 3 2 1 0 result" "brad;andy;bill;ken")
29 LIST(GET mylist -1 -2 -3 -4 result)
30 TEST("GET mylist -1 -2 -3 -4 result" "brad;ken;bill;andy")
32 LIST(GET mylist -1 2 -3 0 result)
33 TEST("GET mylist -1 2 -3 0 ${result}" "brad;ken;bill;andy")
35 LIST(GET "nonexiting_list2" 1 result)
36 TEST("GET \"nonexiting_list2\" 1 result" "NOTFOUND")
38 SET(result andy)
39 LIST(APPEND result brad)
40 TEST("APPEND result brad" "andy;brad")
42 LIST(APPEND "nonexiting_list3" brad)
43 SET(result "${nonexiting_list3}")
44 TEST("APPEND \"nonexiting_list3\" brad" "brad")
46 LIST(INSERT "nonexiting_list4" 0 andy bill brad ken)
47 SET(result "${nonexiting_list4}")
48 TEST("APPEND \"nonexiting_list4\" andy bill brad ken" "andy;bill;brad;ken")
50 SET(result andy brad)
51 LIST(INSERT result -1 bill ken)
52 TEST("INSERT result -1 bill ken" "andy;bill;ken;brad")
54 SET(result andy bill brad ken bob)
55 LIST(REMOVE_ITEM result bob)
56 TEST("REMOVE_ITEM result bob" "andy;bill;brad;ken")
58 SET(result andy bill bob brad ken peter)
59 LIST(REMOVE_ITEM result peter bob)
60 TEST("REMOVE_ITEM result peter bob" "andy;bill;brad;ken")
62 SET(result bob andy bill bob brad ken bob)
63 LIST(REMOVE_ITEM result bob)
64 TEST("REMOVE_ITEM result bob" "andy;bill;brad;ken")
66 SET(result andy bill bob brad ken peter)
67 LIST(REMOVE_AT result 2 -1)
68 TEST("REMOVE_AT result 2 -1" "andy;bill;brad;ken")
70 # ken is at index 2, nobody is not in the list so -1 should be returned
71 SET(mylist andy bill ken brad)
72 LIST(FIND mylist ken result)
73 TEST("FIND mylist ken result" "2")
75 LIST(FIND mylist nobody result)
76 TEST("FIND mylist nobody result" "-1")
78 SET(result ken bill andy brad)
79 LIST(SORT result)
80 TEST("SORT result" "andy;bill;brad;ken")
82 SET(result andy bill brad ken)
83 LIST(REVERSE result)
84 TEST("REVERSE result" "ken;brad;bill;andy")
86 SET(result bill andy bill brad ken ken ken)
87 LIST(REMOVE_DUPLICATES result)
88 TEST("REMOVE_DUPLICATES result" "bill;andy;brad;ken")