Fixed bug that size_ is not updated when WrDiskCacheEntry::append is called

pull/36/head
Tatsuhiro Tsujikawa 2012-12-06 03:04:05 +09:00
parent 838949ab85
commit df5f1fe77f
2 changed files with 2 additions and 0 deletions

View File

@ -116,6 +116,7 @@ size_t WrDiskCacheEntry::append(int64_t goff, const unsigned char *data,
size_t wlen = std::min((*i)->capacity - (*i)->len, len);
memcpy((*i)->data + (*i)->offset + (*i)->len, data, wlen);
(*i)->len += wlen;
size_ += wlen;
return wlen;
} else {
return 0;

View File

@ -61,6 +61,7 @@ void WrDiskCacheEntryTest::testAppend()
CPPUNIT_ASSERT_EQUAL((size_t)3,
e.append(3, (const unsigned char*)"barbaz", 6));
CPPUNIT_ASSERT_EQUAL((size_t)6, cell->len);
CPPUNIT_ASSERT_EQUAL((size_t)6, e.getSize());
CPPUNIT_ASSERT_EQUAL((size_t)0,
e.append(7, (const unsigned char*)"FOO", 3));