/*
- * Copyright 2013 Facebook, Inc.
+ * Copyright 2014 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
folly::IOBuf* nextBuf;
if (this->offset_ == 0) {
// Can just prepend
- nextBuf = buf.get();
+ nextBuf = this->crtBuf_;
this->crtBuf_->prependChain(std::move(buf));
} else {
std::unique_ptr<folly::IOBuf> remaining;
/*
- * Copyright 2013 Facebook, Inc.
+ * Copyright 2014 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
cursor.skip(1);
cursor.insert(std::move(cloned));
- EXPECT_EQ(6, iobuf1->countChainElements());
+ cursor.insert(folly::IOBuf::create(0));
+ EXPECT_EQ(7, iobuf1->countChainElements());
EXPECT_EQ(14, iobuf1->computeChainDataLength());
- // Check that nextBuf got set correctly
+ // Check that nextBuf got set correctly to the buffer with 1 byte left
+ EXPECT_EQ(1, cursor.peek().second);
cursor.read<uint8_t>();
}
cursor.skip(1);
cursor.insert(std::move(cloned));
- EXPECT_EQ(7, iobuf1->countChainElements());
+ EXPECT_EQ(8, iobuf1->countChainElements());
EXPECT_EQ(15, iobuf1->computeChainDataLength());
// Check that nextBuf got set correctly
cursor.read<uint8_t>();
EXPECT_EQ(1, cloned->computeChainDataLength());
cursor.insert(std::move(cloned));
- EXPECT_EQ(8, iobuf1->countChainElements());
+ EXPECT_EQ(9, iobuf1->countChainElements());
EXPECT_EQ(16, iobuf1->computeChainDataLength());
// Check that nextBuf got set correctly
cursor.read<uint8_t>();