diff options
author | Brad King <brad.king@kitware.com> | 2021-12-22 13:52:41 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2021-12-22 13:53:02 (GMT) |
commit | 69eb5b24219c4e50ba520a46264443c3091803af (patch) | |
tree | 70917da7c20a6ddaf782eff51f9bbc96c12680f8 /Tests | |
parent | 217f363cac32c59ee05ccc4856396a099150475b (diff) | |
parent | b573a732dc654f82bd70aeb53666fcf61f26ca16 (diff) | |
download | CMake-69eb5b24219c4e50ba520a46264443c3091803af.zip CMake-69eb5b24219c4e50ba520a46264443c3091803af.tar.gz CMake-69eb5b24219c4e50ba520a46264443c3091803af.tar.bz2 |
Merge topic 'doc-list-non-existent'
b573a732dc Tests: add tests to check claims in the documentation
b151db01f9 Help: mention non-existent case for list(PREPEND)
b3a249c2cb Help: clarify range for list(INSERT), mention nonexistent / empty case
b6fdcb3df0 Help: clarify description of list(INSERT)
e55f473ea9 Help: clarify that list(APPEND) on a non-existent list creates it
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !6824
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/RunCMake/list/LIST-nonexistent.cmake | 45 | ||||
-rw-r--r-- | Tests/RunCMake/list/RunCMakeTest.cmake | 3 |
2 files changed, 48 insertions, 0 deletions
diff --git a/Tests/RunCMake/list/LIST-nonexistent.cmake b/Tests/RunCMake/list/LIST-nonexistent.cmake new file mode 100644 index 0000000..ee88548 --- /dev/null +++ b/Tests/RunCMake/list/LIST-nonexistent.cmake @@ -0,0 +1,45 @@ +# Various list operations should treat non-existent variables as empty +# - APPEND +# - PREPEND +# - INSERT (only valid index is 0) +set(nex_l0 "") +list(APPEND nex_l0 a) +list(APPEND nex_l0 b) +if(NOT nex_l0 STREQUAL "a;b") + message(FATAL_ERROR "a;b expected, got ${nex_l0}") +endif() + +unset(nex_l1) +list(APPEND nex_l1 c) +list(APPEND nex_l1 d) +if(NOT nex_l1 STREQUAL "c;d") + message(FATAL_ERROR "c;d expected, got ${nex_l1}") +endif() + +set(nex_l2 "") +list(PREPEND nex_l2 E) +list(PREPEND nex_l2 f) +if(NOT nex_l2 STREQUAL "f;E") + message(FATAL_ERROR "f;E expected, got ${nex_l2}") +endif() + +unset(nex_l3) +list(PREPEND nex_l3 hi) +list(PREPEND nex_l3 G) +if(NOT nex_l3 STREQUAL "G;hi") + message(FATAL_ERROR "G;hi expected, got ${nex_l3}") +endif() + +set(nex_l4 "") +list(INSERT nex_l4 0 j) +list(INSERT nex_l4 0 kl) +if(NOT nex_l4 STREQUAL "kl;j") + message(FATAL_ERROR "kl;j expected, got ${nex_l4}") +endif() + +unset(nex_l5) +list(INSERT nex_l5 0 M) +list(INSERT nex_l5 0 noP) +if(NOT nex_l5 STREQUAL "noP;M") + message(FATAL_ERROR "noP;M expected, got ${nex_l5}") +endif() diff --git a/Tests/RunCMake/list/RunCMakeTest.cmake b/Tests/RunCMake/list/RunCMakeTest.cmake index eb43ee0..adfe255 100644 --- a/Tests/RunCMake/list/RunCMakeTest.cmake +++ b/Tests/RunCMake/list/RunCMakeTest.cmake @@ -116,3 +116,6 @@ run_cmake(POP_FRONT-NoArgs) # Successful tests run_cmake(POP_BACK) run_cmake(POP_FRONT) + +# Nonexistent variables treated as empty +run_cmake(LIST-nonexistent) |