summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/ADT/STLExtrasTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/unittests/ADT/STLExtrasTest.cpp')
-rw-r--r--llvm/unittests/ADT/STLExtrasTest.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/llvm/unittests/ADT/STLExtrasTest.cpp b/llvm/unittests/ADT/STLExtrasTest.cpp
index 76881296db6..d3bef6a2e05 100644
--- a/llvm/unittests/ADT/STLExtrasTest.cpp
+++ b/llvm/unittests/ADT/STLExtrasTest.cpp
@@ -10,6 +10,7 @@
#include "llvm/ADT/STLExtras.h"
#include "gtest/gtest.h"
+#include <list>
#include <vector>
using namespace llvm;
@@ -253,4 +254,26 @@ TEST(STLExtrasTest, CountAdaptor) {
EXPECT_EQ(1, count(v, 3));
EXPECT_EQ(1, count(v, 4));
}
+
+TEST(STLExtrasTest, ConcatRange) {
+ std::vector<int> Expected = {1, 2, 3, 4, 5, 6, 7, 8};
+ std::vector<int> Test;
+
+ std::vector<int> V1234 = {1, 2, 3, 4};
+ std::list<int> L56 = {5, 6};
+ SmallVector<int, 2> SV78 = {7, 8};
+
+ // Use concat across different sized ranges of different types with different
+ // iterators.
+ for (int &i : concat<int>(V1234, L56, SV78))
+ Test.push_back(i);
+ EXPECT_EQ(Expected, Test);
+
+ // Use concat between a temporary, an L-value, and an R-value to make sure
+ // complex lifetimes work well.
+ Test.clear();
+ for (int &i : concat<int>(std::vector<int>(V1234), L56, std::move(SV78)))
+ Test.push_back(i);
+ EXPECT_EQ(Expected, Test);
+}
}
OpenPOWER on IntegriCloud