本文整理汇总了C++中TestObject::getDataLen方法的典型用法代码示例。如果您正苦于以下问题:C++ TestObject::getDataLen方法的具体用法?C++ TestObject::getDataLen怎么用?C++ TestObject::getDataLen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TestObject
的用法示例。
在下文中一共展示了TestObject::getDataLen方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: serializer
bool serializer(TestObject* data, tbnet::DataBuffer** dataBuffer) {
TestObject* node = (TestObject*)data;
char* t_value = node->getData();
int t_value_len = node->getDataLen();
tbnet::DataBuffer* buffer = new tbnet::DataBuffer();
buffer->writeInt32(t_value_len);
buffer->writeBytes(t_value,t_value_len);
(*dataBuffer) = buffer;
return true;
}
示例2: while
TEST(test_large_unvisibe_char_2_test_file_refresh, DISKQUEUE_MULTI_READ_MULTI_WRITE) {
DiskQueue<TestObject> disk_queue("queue/lisi", 1, 1024*1024*10, serializer, deserializer);
ASSERT_EQ(1, disk_queue.empty());
ASSERT_STREQ("queue/lisi", disk_queue.getQueueName());
ASSERT_EQ(1, disk_queue.getMode());
ASSERT_EQ(1024*1024*10, disk_queue.getMaxFileSize());
int i;
std::queue<TestObject*> TestObjectQueue;
for(i = 0; i < 1024*10; i++) {//10M * 10
TestObject* tmp = TestObject::createRandomOne(1024, 1);
TestObject* tmp1 = tmp->copy();
TestObjectQueue.push(tmp1);
ASSERT_EQ(1, disk_queue.push(tmp));
}
int index = 0;
while(!TestObjectQueue.empty()) {
TestObject* tmp = TestObjectQueue.front();
TestObjectQueue.pop();
TestObject* tmp2 = NULL;
ASSERT_EQ(0, disk_queue.empty());
ASSERT_EQ(1, disk_queue.pop(&tmp2));
int data_len = tmp->getDataLen();
char* adata = tmp->getData();
char* bdata = tmp2->getData();
for(i = 0; i < data_len; i++) {
ASSERT_EQ(adata[i], bdata[i]);
}
delete tmp;
delete tmp2;
index++;
}
}