mirror of
https://github.com/facebookincubator/mvfst.git
synced 2025-11-27 03:41:14 +03:00
Add unit test for BufQueue::clone
Summary: As titled. Reviewed By: afrind Differential Revision: D42036127 fbshipit-source-id: ae7fa598bd233e14261011be62de7e25f7d16ca2
This commit is contained in:
committed by
Facebook GitHub Bot
parent
c3bdb45817
commit
0e39de88f3
@@ -176,6 +176,28 @@ TEST(BufQueue, TrimStartAtMost) {
|
|||||||
checkConsistency(queue);
|
checkConsistency(queue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(BufQueue, CloneBufNull) {
|
||||||
|
BufQueue queue;
|
||||||
|
auto buf = queue.clone();
|
||||||
|
EXPECT_EQ(nullptr, buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(BufQueue, CloneBuf) {
|
||||||
|
std::string s("Hello, World");
|
||||||
|
BufQueue queue;
|
||||||
|
queue.append(IOBuf::copyBuffer(s.data(), s.length()));
|
||||||
|
auto buf = queue.clone();
|
||||||
|
const IOBuf* chain = queue.front();
|
||||||
|
EXPECT_EQ(s.length(), chain->computeChainDataLength());
|
||||||
|
EXPECT_EQ(s.length(), buf->computeChainDataLength());
|
||||||
|
EXPECT_EQ(0, memcmp(chain->data(), buf->data(), s.length()));
|
||||||
|
queue.append(IOBuf::copyBuffer(s.data(), s.length()));
|
||||||
|
EXPECT_EQ(2 * s.length(), chain->computeChainDataLength());
|
||||||
|
EXPECT_EQ(s.length(), buf->computeChainDataLength());
|
||||||
|
buf = queue.clone();
|
||||||
|
EXPECT_EQ(2 * s.length(), buf->computeChainDataLength());
|
||||||
|
}
|
||||||
|
|
||||||
TEST(BufAppender, TestPushAlreadyFits) {
|
TEST(BufAppender, TestPushAlreadyFits) {
|
||||||
std::unique_ptr<folly::IOBuf> data = folly::IOBuf::create(10);
|
std::unique_ptr<folly::IOBuf> data = folly::IOBuf::create(10);
|
||||||
BufAppender appender(data.get(), 10);
|
BufAppender appender(data.get(), 10);
|
||||||
|
|||||||
Reference in New Issue
Block a user