本文整理汇总了C++中DataBuffer::findBytes方法的典型用法代码示例。如果您正苦于以下问题:C++ DataBuffer::findBytes方法的具体用法?C++ DataBuffer::findBytes怎么用?C++ DataBuffer::findBytes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataBuffer
的用法示例。
在下文中一共展示了DataBuffer::findBytes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testFindBytes
void DataBufferTF::testFindBytes()
{
DataBuffer buffer;
buffer.writeBytes("start", 5);
const char *content = "just for test";
int len = 13;
buffer.writeBytes(content, len);
CPPUNIT_ASSERT(buffer.findBytes((const char*)content, len >= 0));
}
示例2: testShrink
void DataBufferTF::testShrink()
{
DataBuffer buffer;
buffer.shrink();
CPPUNIT_ASSERT(!buffer._pstart);
buffer.expand(1);
void *old_pstart = buffer._pstart;
if (buffer._pend - buffer._pstart <= MAX_BUFFER_SIZE) {
buffer.shrink();
CPPUNIT_ASSERT_EQUAL(old_pstart, (void *)buffer._pstart);
}
const char *content = "just for test";
int len = 14;
buffer.writeBytes(content, len);
buffer.expand(MAX_BUFFER_SIZE);
old_pstart = buffer._pstart;
int datalen = buffer._pstart - buffer._pfree;
buffer.shrink();
CPPUNIT_ASSERT(old_pstart != buffer._pstart);
CPPUNIT_ASSERT(buffer.findBytes((const char *)content, len) >= 0);
CPPUNIT_ASSERT(old_pstart != buffer._pstart);
CPPUNIT_ASSERT_EQUAL(datalen,(int)(buffer._pstart - buffer._pfree));
CPPUNIT_ASSERT_EQUAL((int)(buffer._pend - buffer._pstart), MAX_BUFFER_SIZE);
}