]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
test/bufferlist: add copy_all test
authorColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Tue, 7 Jun 2011 19:05:50 +0000 (12:05 -0700)
committerColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Tue, 7 Jun 2011 19:05:50 +0000 (12:05 -0700)
Signed-off-by: Colin McCabe <colin.mccabe@dreamhost.com>
src/test/bufferlist.cc

index 22649e62e0698d3e51232ad9e0318f726452d5aa..328c5f0f887de25bf9aa7e4f6fd47d280c58fae1 100644 (file)
@@ -53,3 +53,21 @@ TEST(BufferList, TestDirectAppend) {
   }
   ASSERT_EQ(memcmp(bl.c_str(), correct, curpos), 0);
 }
+
+TEST(BufferList, TestCopyAll) {
+  const static size_t BIG_SZ = 10737414;
+  unsigned char big[BIG_SZ];
+  unsigned char c = 0;
+  for (size_t i = 0; i < BIG_SZ; ++i) {
+    big[i] = c++;
+  }
+  bufferlist bl;
+  bl.append((const char*)big, BIG_SZ);
+  bufferlist::iterator i = bl.begin();
+  bufferlist bl2;
+  i.copy_all(bl2);
+  ASSERT_EQ(bl2.length(), BIG_SZ);
+  unsigned char big2[BIG_SZ];
+  bl2.copy(0, BIG_SZ, (char*)big2);
+  ASSERT_EQ(memcmp(big, big2, BIG_SZ), 0);
+}