}
}
+template <typename T, unsigned N>
+static unsigned NumBuiltinElts(const SmallVector<T, N> &) {
+ return N;
+}
+
class SmallVectorTestBase : public testing::Test {
protected:
void SetUp() override { Constructable::reset(); }
protected:
VectorT1 theVector;
VectorT2 otherVector;
-
- template <typename T, unsigned N>
- static unsigned NumBuiltinElts(const SmallVector<T, N>&) { return N; }
};
typedef ::testing::Types<
// If the source vector (otherVector) was in small-mode, assert that we just
// moved the data pointer over.
- EXPECT_TRUE(this->NumBuiltinElts(U) == 4 || V.data() == OrigDataPtr);
+ EXPECT_TRUE(NumBuiltinElts(U) == 4 || V.data() == OrigDataPtr);
// There shouldn't be any live objects any more.
V.clear();
VectorT V;
- template <typename T, unsigned N>
- static unsigned NumBuiltinElts(const SmallVector<T, N> &) {
- return N;
- }
-
template <class T> static bool isValueType() {
return std::is_same<T, typename VectorT::value_type>::value;
}
TYPED_TEST(SmallVectorReferenceInvalidationTest, PushBack) {
// Note: setup adds [1, 2, ...] to V until it's at capacity in small mode.
auto &V = this->V;
- int N = this->NumBuiltinElts(V);
+ int N = NumBuiltinElts(V);
// Push back a reference to last element when growing from small storage.
V.push_back(V.back());
TYPED_TEST(SmallVectorReferenceInvalidationTest, PushBackMoved) {
// Note: setup adds [1, 2, ...] to V until it's at capacity in small mode.
auto &V = this->V;
- int N = this->NumBuiltinElts(V);
+ int N = NumBuiltinElts(V);
// Push back a reference to last element when growing from small storage.
V.push_back(std::move(V.back()));
TYPED_TEST(SmallVectorReferenceInvalidationTest, Resize) {
auto &V = this->V;
(void)V;
- int N = this->NumBuiltinElts(V);
+ int N = NumBuiltinElts(V);
V.resize(N + 1, V.back());
EXPECT_EQ(N, V.back());
auto &V = this->V;
(void)V;
V.append(1, V.back());
- int N = this->NumBuiltinElts(V);
+ int N = NumBuiltinElts(V);
EXPECT_EQ(N, V[N - 1]);
// Append enough more elements that V will grow again. This tests growing
#if !defined(NDEBUG) && GTEST_HAS_DEATH_TEST
EXPECT_DEATH(V.append(V.begin(), V.begin() + 1), this->AssertionMessage);
- ASSERT_EQ(3u, this->NumBuiltinElts(V));
+ ASSERT_EQ(3u, NumBuiltinElts(V));
ASSERT_EQ(3u, V.size());
V.pop_back();
ASSERT_EQ(2u, V.size());
// Note: setup adds [1, 2, ...] to V until it's at capacity in small mode.
auto &V = this->V;
(void)V;
- int N = this->NumBuiltinElts(V);
+ int N = NumBuiltinElts(V);
ASSERT_EQ(unsigned(N), V.size());
ASSERT_EQ(unsigned(N), V.capacity());
// Cover NumToInsert <= this->end() - I.
V.insert(V.begin() + 1, 1, V.back());
- int N = this->NumBuiltinElts(V);
+ int N = NumBuiltinElts(V);
EXPECT_EQ(N, V[1]);
// Cover NumToInsert > this->end() - I, inserting enough elements that V will
EXPECT_DEATH(V.insert(V.begin(), V.begin(), V.begin() + 1),
this->AssertionMessage);
- ASSERT_EQ(3u, this->NumBuiltinElts(V));
+ ASSERT_EQ(3u, NumBuiltinElts(V));
ASSERT_EQ(3u, V.size());
V.pop_back();
ASSERT_EQ(2u, V.size());
TYPED_TEST(SmallVectorReferenceInvalidationTest, EmplaceBack) {
// Note: setup adds [1, 2, ...] to V until it's at capacity in small mode.
auto &V = this->V;
- int N = this->NumBuiltinElts(V);
+ int N = NumBuiltinElts(V);
// Push back a reference to last element when growing from small storage.
V.emplace_back(V.back());
TYPED_TEST(SmallVectorInternalReferenceInvalidationTest, EmplaceBack) {
// Note: setup adds [1, 2, ...] to V until it's at capacity in small mode.
auto &V = this->V;
- int N = this->NumBuiltinElts(V);
+ int N = NumBuiltinElts(V);
// Push back a reference to last element when growing from small storage.
V.emplace_back(V.back().first, V.back().second);