diff options
Diffstat (limited to 'llvm/unittests/ADT/SmallVectorTest.cpp')
-rw-r--r-- | llvm/unittests/ADT/SmallVectorTest.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/llvm/unittests/ADT/SmallVectorTest.cpp b/llvm/unittests/ADT/SmallVectorTest.cpp index 74b6561..957412f 100644 --- a/llvm/unittests/ADT/SmallVectorTest.cpp +++ b/llvm/unittests/ADT/SmallVectorTest.cpp @@ -983,6 +983,22 @@ TEST(SmallVectorTest, EmplaceBack) { } } +TEST(SmallVectorTest, DefaultInlinedElements) { + SmallVector<int> V; + EXPECT_TRUE(V.empty()); + V.push_back(7); + EXPECT_EQ(V[0], 7); + + // Check that at least a couple layers of nested SmallVector<T>'s are allowed + // by the default inline elements policy. This pattern happens in practice + // with some frequency, and it seems fairly harmless even though each layer of + // SmallVector's will grow the total sizeof by a vector header beyond the + // "preferred" maximum sizeof. + SmallVector<SmallVector<SmallVector<int>>> NestedV; + NestedV.emplace_back().emplace_back().emplace_back(42); + EXPECT_EQ(NestedV[0][0][0], 42); +} + TEST(SmallVectorTest, InitializerList) { SmallVector<int, 2> V1 = {}; EXPECT_TRUE(V1.empty()); |