Summary:
impl_.e_ += newB - impl_.b_; fails when the difference
between newB and impl_.b_ isn't a multiple of sizeof(T).
Test Plan: .
Reviewed By: oyamauchi@fb.com
FB internal diff:
D774754
if (impl_.b_)
M_deallocate(impl_.b_, impl_.z_ - impl_.b_);
impl_.z_ = newB + newCap;
- impl_.e_ += newB - impl_.b_; // speed hax
+ impl_.e_ = newB + (impl_.e_ - impl_.b_);
impl_.b_ = newB;
}
if (impl_.b_)
M_deallocate(impl_.b_, impl_.z_ - impl_.b_);
impl_.z_ = newB + newCap;
- impl_.e_ += newB - impl_.b_; // speed hax
+ impl_.e_ = newB + (impl_.e_ - impl_.b_);
impl_.b_ = newB;
}
}
EXPECT_EQ(fbvi3, base);
}
+TEST(FBVector, reserve_consistency) {
+ struct S { int64_t a, b, c, d; };
+
+ fbvector<S> fb1;
+ for (size_t i = 0; i < 1000; ++i) {
+ fb1.reserve(1);
+ EXPECT_EQ(fb1.size(), 0);
+ fb1.shrink_to_fit();
+ }
+}
+
int main(int argc, char** argv) {
testing::InitGoogleTest(&argc, argv);
google::ParseCommandLineFlags(&argc, &argv, true);