Skip to content

Commit

Permalink
test/bufferlist: add test case for bufferlist::splice.
Browse files Browse the repository at this point in the history
Signed-off-by: Jianpeng Ma <[email protected]>
  • Loading branch information
majianpeng committed May 4, 2015
1 parent 1006adb commit 3034213
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/test/bufferlist.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1865,6 +1865,18 @@ TEST(BufferList, splice) {
bl.splice(4, 4);
EXPECT_EQ((unsigned)4, bl.length());
EXPECT_EQ(0, ::memcmp("ABCD", bl.c_str(), bl.length()));

{
bl.clear();
bufferptr ptr1("0123456789", 10);
bl.push_back(ptr1);
bufferptr ptr2("abcdefghij", 10);
bl.append(ptr2, 5, 5);
other.clear();
bl.splice(10, 4, &other);
EXPECT_EQ((unsigned)11, bl.length());
EXPECT_EQ(0, ::memcmp("fghi", other.c_str(), other.length()));
}
}

TEST(BufferList, write) {
Expand Down

0 comments on commit 3034213

Please sign in to comment.