Skip to content

Commit

Permalink
Merge pull request chenshuo#189 from weizili/buffer
Browse files Browse the repository at this point in the history
Modify the test cases of Buffer
  • Loading branch information
chenshuo committed May 28, 2016
2 parents ea480fd + 2ebba8f commit 085002f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions muduo/net/tests/Buffer_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ BOOST_AUTO_TEST_CASE(testBufferAppendRetrieve)
BOOST_CHECK_EQUAL(buf.readableBytes(), str.size() - str2.size());
BOOST_CHECK_EQUAL(buf.writableBytes(), Buffer::kInitialSize - str.size());
BOOST_CHECK_EQUAL(buf.prependableBytes(), Buffer::kCheapPrepend + str2.size());
BOOST_CHECK_EQUAL(str2, string(50, 'x'));

buf.append(str);
BOOST_CHECK_EQUAL(buf.readableBytes(), 2*str.size() - str2.size());
Expand All @@ -37,6 +38,7 @@ BOOST_AUTO_TEST_CASE(testBufferAppendRetrieve)
BOOST_CHECK_EQUAL(buf.readableBytes(), 0);
BOOST_CHECK_EQUAL(buf.writableBytes(), Buffer::kInitialSize);
BOOST_CHECK_EQUAL(buf.prependableBytes(), Buffer::kCheapPrepend);
BOOST_CHECK_EQUAL(str3, string(350, 'x'));
}

BOOST_AUTO_TEST_CASE(testBufferGrow)
Expand Down Expand Up @@ -133,12 +135,12 @@ BOOST_AUTO_TEST_CASE(testBufferReadInt)
BOOST_CHECK_EQUAL(buf.writableBytes(), Buffer::kInitialSize);

buf.appendInt8(-1);
buf.appendInt16(-1);
buf.appendInt32(-1);
buf.appendInt16(-2);
buf.appendInt32(-3);
BOOST_CHECK_EQUAL(buf.readableBytes(), 7);
BOOST_CHECK_EQUAL(buf.readInt8(), -1);
BOOST_CHECK_EQUAL(buf.readInt32(), -1);
BOOST_CHECK_EQUAL(buf.readInt16(), -1);
BOOST_CHECK_EQUAL(buf.readInt16(), -2);
BOOST_CHECK_EQUAL(buf.readInt32(), -3);
}

BOOST_AUTO_TEST_CASE(testBufferFindEOL)
Expand Down

0 comments on commit 085002f

Please sign in to comment.