summaryrefslogtreecommitdiffstats
path: root/Tests/CMakeTests/ListTest.cmake.in
blob: d1e8c2b690d911b5561c632faf4041a09799f997 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
MACRO(TEST command expected)
  IF("x${result}" STREQUAL "x${expected}")
    MESSAGE("TEST \"${command}\" success: \"${result}\" expected: \"${expected}\"")
  ELSE("x${result}" STREQUAL "x${expected}")
    MESSAGE(SEND_ERROR "TEST \"${command}\" failed: \"${result}\" expected: \"${expected}\"")
  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")

LIST(LENGTH "nonexiting_list1" result)
TEST("LENGTH \"nonexiting_list1\" result" "0")

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")

LIST(GET "nonexiting_list2" 1 result)
TEST("GET \"nonexiting_list2\" 1 result" "NOTFOUND")

SET(result andy)
LIST(APPEND result brad)
TEST("APPEND result brad" "andy;brad")

LIST(APPEND "nonexiting_list3" brad)
SET(result "${nonexiting_list3}")
TEST("APPEND \"nonexiting_list1\" brad" "brad")

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)
LIST(REMOVE result bob)
TEST("REMOVE result bob" "andy;bill;brad;ken")

SET(result andy bill bob brad ken peter)
LIST(REMOVE result peter bob)
TEST("REMOVE result peter bob" "andy;bill;brad;ken")

SET(result andy bill bob brad ken peter)
LIST(REMOVE_ITEM result 2 -1)
TEST("REMOVE_ITEM result 2 -1" "andy;bill;brad;ken")