/*
- * Copyright 2016 Facebook, Inc.
+ * Copyright 2017 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
{ // 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_;
+ } dummyRefCounted;
+ EXPECT_EQ(
+ str.capacity(),
+ goodMallocSize(3840) - sizeof(dummyRefCounted) - sizeof(char));
+ }
}
TEST(FBString, findWithNpos) {
EXPECT_TRUE(t2.stringMember.empty());
EXPECT_EQ(allocatorConstructedCount.load(), 1);
}
+
+TEST(FBStringCtorTest, NullZeroConstruction) {
+ char* p = nullptr;
+ int n = 0;
+ folly::fbstring f(p, n);
+ EXPECT_EQ(f.size(), 0);
+}