Explorar o código

Merge topic 'cmList-SUBLIST-regression'

1cfaed0684 list(): restore SUBLIST behavior

Acked-by: Kitware Robot <[email protected]>
Tested-by: buildbot <[email protected]>
Merge-request: !8569
Brad King %!s(int64=2) %!d(string=hai) anos
pai
achega
8bfef726fa
Modificáronse 2 ficheiros con 52 adicións e 1 borrados
  1. 1 1
      Source/cmList.h
  2. 51 0
      Tests/RunCMake/list/SUBLIST.cmake

+ 1 - 1
Source/cmList.h

@@ -322,7 +322,7 @@ public:
   // extract sublist in range [first, last)
   cmList sublist(const_iterator first, const_iterator last) const
   {
-    return cmList{ first, last };
+    return cmList{ first, last, ExpandElements::No, EmptyElements::Yes };
   }
   // Extract sublist in range [first, last)
   // Throw std::out_of_range if pos is invalid

+ 51 - 0
Tests/RunCMake/list/SUBLIST.cmake

@@ -44,3 +44,54 @@ 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()
+
+
+set(mylist ";;")
+
+unset(result)
+list(SUBLIST mylist 0 0 result)
+
+if (NOT result STREQUAL "")
+  message (FATAL_ERROR "SUBLIST is \"${result}\", expected is \"\"")
+endif()
+
+unset(result)
+list(SUBLIST mylist 0 1 result)
+
+if (NOT result STREQUAL "")
+  message (FATAL_ERROR "SUBLIST is \"${result}\", expected is \"\"")
+endif()
+
+unset(result)
+list(SUBLIST mylist 0 2 result)
+
+if (NOT result STREQUAL ";")
+  message (FATAL_ERROR "SUBLIST is \"${result}\", expected is \";\"")
+endif()
+
+unset(result)
+list(SUBLIST mylist 0 3 result)
+
+if (NOT result STREQUAL ";;")
+  message (FATAL_ERROR "SUBLIST is \"${result}\", expected is \";;\"")
+endif()
+
+
+set(mylist [[a\;b;c\;d;e]])
+
+unset(result)
+list(SUBLIST mylist 1 2 result)
+
+if (NOT result STREQUAL "c;d;e")
+  message (FATAL_ERROR "SUBLIST is \"${result}\", expected is \"c;d;e\"")
+endif()
+
+
+set(mylist [[a\;b;c\\;d;e;f;g;h]])
+
+unset(result)
+list(SUBLIST mylist 1 -1 result)
+
+if (NOT result STREQUAL "c\\;d;e;f;g;h")
+  message (FATAL_ERROR "SUBLIST is \"${result}\", expected is \"c\\;d;e;f;g;h\"")
+endif()