Fix bug where capacity is not updated correctly after reserveLarge()
[folly.git] / folly / test / FBStringTest.cpp
index fb4a79912f044edeb303d2abbd653f07bc7cc224..6c6f099cac711a06dee53961276e1192e8e06e7f 100644 (file)
@@ -1270,6 +1270,17 @@ TEST(FBString, testFixedBugs) {
   { // D3698862
     EXPECT_EQ(fbstring().find(fbstring(), 4), fbstring::npos);
   }
+  if (usingJEMalloc()) { // D4355440
+    fbstring str(1337, 'f');
+    str.reserve(3840);
+    EXPECT_NE(str.capacity(), 3840);
+
+    struct {
+      std::atomic<size_t> refCount_;
+      char data_[1];
+    } dummyRefCounted;
+    EXPECT_EQ(str.capacity(), goodMallocSize(3840) - sizeof(dummyRefCounted));
+  }
 }
 
 TEST(FBString, findWithNpos) {