[PATCH] D23890: Fix ArrayRef initializer_list Ctor Test

Erich Keane via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 25 13:16:33 PDT 2016


erichkeane updated this revision to Diff 69288.
erichkeane added a comment.

Switched test to a lambda.  BTW, I don't have commit rights, so if this gets approved and someone would commit for me, I'd be very appreciative.

Thanks!


Repository:
  rL LLVM

https://reviews.llvm.org/D23890

Files:
  unittests/ADT/ArrayRefTest.cpp

Index: unittests/ADT/ArrayRefTest.cpp
===================================================================
--- unittests/ADT/ArrayRefTest.cpp
+++ unittests/ADT/ArrayRefTest.cpp
@@ -134,7 +134,8 @@
 }
 
 TEST(ArrayRefTest, InitializerList) {
-  ArrayRef<int> A = { 0, 1, 2, 3, 4 };
+  std::initializer_list<int> init_list = { 0, 1, 2, 3, 4 };
+  ArrayRef<int> A = init_list;
   for (int i = 0; i < 5; ++i)
     EXPECT_EQ(i, A[i]);
 
@@ -146,6 +147,17 @@
   ArgTest12({1, 2});
 }
 
+// A more realistic test for the Init-list ctor
+TEST(ArrayRefTest, InitializerListTemporary) {
+  auto func =[](ArrayRef<int> A) { 
+    for (int i = 0; i < 5; ++i)
+      EXPECT_EQ(i, A[i]);
+  };
+
+  func({0, 1, 2, 3, 4 });
+}
+  
+
 // Test that makeArrayRef works on ArrayRef (no-op)
 TEST(ArrayRefTest, makeArrayRef) {
   static const int A1[] = {1, 2, 3, 4, 5, 6, 7, 8};


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D23890.69288.patch
Type: text/x-patch
Size: 859 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160825/0d93bb54/attachment.bin>


More information about the llvm-commits mailing list