
include ("${RunCMake_SOURCE_DIR}/check_errors.cmake")
unset (errors)

set(listvar ALPHA BRAVO CHARLIE DELTA)

list(TRANSFORM listvar TOLOWER OUTPUT_VARIABLE reference)
set (output "$<LIST:TRANSFORM,ALPHA;BRAVO;CHARLIE;DELTA,TOLOWER>")
if (NOT output STREQUAL reference)
  list (APPEND errors "returns bad value: ${output}")
endif()

list(TRANSFORM listvar TOLOWER AT 1 3 OUTPUT_VARIABLE reference)
set (output "$<LIST:TRANSFORM,ALPHA;BRAVO;CHARLIE;DELTA,TOLOWER,AT,1,3>")
if (NOT output STREQUAL reference)
  list (APPEND errors "returns bad value: ${output}")
endif()

list(TRANSFORM listvar TOLOWER AT 1 -2 OUTPUT_VARIABLE reference)
set (output "$<LIST:TRANSFORM,ALPHA;BRAVO;CHARLIE;DELTA,TOLOWER,AT,1,-2>")
if (NOT output STREQUAL reference)
  list (APPEND errors "returns bad value: ${output}")
endif()

list(TRANSFORM listvar TOLOWER FOR 1 2 OUTPUT_VARIABLE reference)
set (output "$<LIST:TRANSFORM,ALPHA;BRAVO;CHARLIE;DELTA,TOLOWER,FOR,1,2>")
if (NOT output STREQUAL reference)
  list (APPEND errors "returns bad value: ${output}")
endif()

list(TRANSFORM listvar TOLOWER FOR 1 -1 OUTPUT_VARIABLE reference)
set (output "$<LIST:TRANSFORM,ALPHA;BRAVO;CHARLIE;DELTA,TOLOWER,FOR,1,-1>")
if (NOT output STREQUAL reference)
  list (APPEND errors "returns bad value: ${output}")
endif()

list(TRANSFORM listvar TOLOWER FOR 1 -1 2 OUTPUT_VARIABLE reference)
set (output "$<LIST:TRANSFORM,ALPHA;BRAVO;CHARLIE;DELTA,TOLOWER,FOR,1,-1,2>")
if (NOT output STREQUAL reference)
  list (APPEND errors "returns bad value: ${output}")
endif()

list(TRANSFORM listvar TOLOWER REGEX "(R|T)A" OUTPUT_VARIABLE reference)
set (output "$<LIST:TRANSFORM,ALPHA;BRAVO;CHARLIE;DELTA,TOLOWER,REGEX,(R|T)A>")
if (NOT output STREQUAL reference)
  list (APPEND errors "returns bad value: ${output}")
endif()


check_errors("LIST:TRANSFORM,TOLOWER..." ${errors})
