diff options
author | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-18 01:54:55 +0000 |
---|---|---|
committer | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-18 01:54:55 +0000 |
commit | e609bb94b0cf64a4373261854cfa45cfa87f6004 (patch) | |
tree | c8c18ff14831d9a2cf0ea1c7f7993c3bd35dc996 /remoting/base/compound_buffer_unittest.cc | |
parent | 7ed9caae9a7f7117d8d20bc2057d434ccf192908 (diff) | |
download | chromium_src-e609bb94b0cf64a4373261854cfa45cfa87f6004.zip chromium_src-e609bb94b0cf64a4373261854cfa45cfa87f6004.tar.gz chromium_src-e609bb94b0cf64a4373261854cfa45cfa87f6004.tar.bz2 |
Use CompoundBuffer in MessageDecoder.
TEST=Unittests
BUG=None
Review URL: http://codereview.chromium.org/5067001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@66574 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/base/compound_buffer_unittest.cc')
-rw-r--r-- | remoting/base/compound_buffer_unittest.cc | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/remoting/base/compound_buffer_unittest.cc b/remoting/base/compound_buffer_unittest.cc index 63ede5a..2b90bfe 100644 --- a/remoting/base/compound_buffer_unittest.cc +++ b/remoting/base/compound_buffer_unittest.cc @@ -24,6 +24,9 @@ const int kChunkSizes1[] = {1, 10, 20, -1}; // Chunk sizes used to test CopyFrom(). const int kCopySizes0[] = {10, 3, -1}; const int kCopySizes1[] = {20, -1}; + +const int kCropSizes[] = {1, -1}; + } // namespace class CompoundBufferTest : public testing::Test { @@ -52,6 +55,22 @@ class CompoundBufferTest : public testing::Test { EXPECT_TRUE(CompareData(copy, data_->data() + pos, size)); } + void TestCropFront(int pos, int size) { + CompoundBuffer cropped; + cropped.CopyFrom(target_, 0, target_.total_bytes()); + cropped.CropFront(pos); + EXPECT_TRUE(CompareData(cropped, data_->data() + pos, + target_.total_bytes() - pos)); + } + + void TestCropBack(int pos, int size) { + CompoundBuffer cropped; + cropped.CopyFrom(target_, 0, target_.total_bytes()); + cropped.CropBack(pos); + EXPECT_TRUE(CompareData(cropped, data_->data(), + target_.total_bytes() - pos)); + } + protected: virtual void SetUp() { data_ = new IOBuffer(kDataSize); @@ -210,6 +229,24 @@ TEST_F(CompoundBufferTest, PrependCopyOf) { EXPECT_TRUE(CompareData(target_, data_->data(), kDataSize)); } +TEST_F(CompoundBufferTest, CropFront) { + target_.Clear(); + IterateOverPieces(kChunkSizes1, NewCallback( + static_cast<CompoundBufferTest*>(this), &CompoundBufferTest::Append)); + IterateOverPieces(kCropSizes, NewCallback( + static_cast<CompoundBufferTest*>(this), + &CompoundBufferTest::TestCropFront)); +} + +TEST_F(CompoundBufferTest, CropBack) { + target_.Clear(); + IterateOverPieces(kChunkSizes1, NewCallback( + static_cast<CompoundBufferTest*>(this), &CompoundBufferTest::Append)); + IterateOverPieces(kCropSizes, NewCallback( + static_cast<CompoundBufferTest*>(this), + &CompoundBufferTest::TestCropBack)); +} + TEST_F(CompoundBufferTest, CopyFrom) { target_.Clear(); IterateOverPieces(kChunkSizes1, NewCallback( |