*/
#include "folly/experimental/io/IOBufQueue.h"
+#include "folly/Range.h"
#include <gflags/gflags.h>
#include <gtest/gtest.h>
using folly::IOBuf;
using folly::IOBufQueue;
+using folly::StringPiece;
using std::pair;
using std::string;
using std::unique_ptr;
EXPECT_GE(4096, writable.second);
}
+TEST(IOBufQueue, Wrap) {
+ IOBufQueue queue(clOptions);
+ const char* buf = "hello world goodbye";
+ size_t len = strlen(buf);
+ queue.wrapBuffer(buf, len, 6);
+ auto iob = queue.move();
+ EXPECT_EQ((len - 1) / 6 + 1, iob->countChainElements());
+ iob->unshare();
+ iob->coalesce();
+ EXPECT_EQ(StringPiece(buf),
+ StringPiece(reinterpret_cast<const char*>(iob->data()),
+ iob->length()));
+}
+
TEST(IOBufQueue, trim) {
IOBufQueue queue(clOptions);
unique_ptr<IOBuf> a = IOBuf::create(4);