TEST(test_large_visibe_char_1, DISKQUEUE_MULTI_READ_ONE_WRITE) { DiskQueue<TestObject> disk_queue("queue/zhangsan", 1, 1024*1024*10, serializer, deserializer); ASSERT_EQ(1, disk_queue.empty()); ASSERT_STREQ("queue/zhangsan", 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*10; i++) {//10M * 10 TestObject* tmp = TestObject::createRandomOne(1024, 0); TestObject* tmp1 = tmp->copy(); TestObjectQueue.push(tmp1); ASSERT_EQ(1, disk_queue.push(tmp)); } 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)); ASSERT_STREQ(tmp->getData(), tmp2->getData()); delete tmp; delete tmp2; } ASSERT_EQ(1, disk_queue.empty()); }
TEST(test_simple_1, DISKQUEUE_ONE_READ_ONE_WRITE) { DiskQueue<TestObject> disk_queue(NULL, 0, 0, serializer, deserializer); ASSERT_EQ(1, disk_queue.empty()); ASSERT_STREQ(".queue.list", disk_queue.getQueueName()); ASSERT_EQ(0, disk_queue.getMode()); ASSERT_EQ(1024*1024*256, disk_queue.getMaxFileSize()); int i; std::queue<TestObject*> TestObjectQueue; for(i = 0; i < 100; i++) { TestObject* tmp = TestObject::createRandomOne(1024, 0); TestObject* tmp1 = tmp->copy(); TestObjectQueue.push(tmp1); ASSERT_EQ(1, disk_queue.push(tmp)); } 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)); ASSERT_STREQ(tmp->getData(), tmp2->getData()); delete tmp; delete tmp2; } ASSERT_EQ(1, disk_queue.empty()); }
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++; } }