summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/list/SUBLIST.cmake
blob: fd15c28447d3bd6f90f378b3ce9ed5303abfaa42 (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
set(mylist alpha bravo charlie delta)
list(SUBLIST mylist 1 2 result)

if (NOT result STREQUAL "bravo;charlie")
  message (FATAL_ERROR "SUBLIST is \"${result}\", expected is \"bravo;charlie\"")
endif()


unset(result)
list(SUBLIST mylist 0 2 result)

if (NOT result STREQUAL "alpha;bravo")
  message (FATAL_ERROR "SUBLIST is \"${result}\", expected is \"alpha;bravo\"")
endif()


unset(result)
list(SUBLIST mylist 3 2 result)

if (NOT result STREQUAL "delta")
  message (FATAL_ERROR "SUBLIST is \"${result}\", expected is \"delta\"")
endif()


unset(result)
list(SUBLIST mylist 2 0 result)
list(LENGTH result length)
if (NOT length EQUAL 0)
  message (FATAL_ERROR "SUBLIST is \"${result}\", expected is an empty list")
endif()


unset(result)
list(SUBLIST mylist 1 5 result)

if (NOT result STREQUAL "bravo;charlie;delta")
  message (FATAL_ERROR "SUBLIST is \"${result}\", expected is \"bravo;charlie;delta\"")
endif()


unset(result)
list(SUBLIST mylist 1 -1 result)

if (NOT result STREQUAL "bravo;charlie;delta")
  message (FATAL_ERROR "SUBLIST is \"${result}\", expected is \"bravo;charlie;delta\"")
endif()