本文整理汇总了C++中TestObject类的典型用法代码示例。如果您正苦于以下问题:C++ TestObject类的具体用法?C++ TestObject怎么用?C++ TestObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TestObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TestObject
void AgentThread::processCMDSTART_REQUEST(int socketHandle)
{
try {
ConsoleServer::debugMsg(1,"Processing CMDSTART_REQUEST\n");
// read the serialized TestObject which we will execute
TestObject *test = new TestObject();
test->readTestObject(socketHandle);
// now send a signal indicating we are processing the request
Utils::sendSignal(socketHandle,RESPONSE_PROCESSING);
// execute the test
ExecProcess *startedProcess = addProcess(new ExecProcess(test,
debugLevel,
showOutput));
startedProcess->run();
ConsoleServer::debugMsg(1,
"Added pid %d to process pool (total %d processes)\n",
startedProcess->getPid(),
getProcessCount());
// now send a signal indicating we have finished
Utils::sendSignal(socketHandle,RESPONSE_FINISHED_OK);
}
catch (char *message) {
ConsoleServer::debugMsg(1,"Error processing CMDSTART_REQUEST execute request:%s\n",message);
Utils::sendSignal(socketHandle,RESPONSE_FINISHED_ERROR);
}
};
示例2: TEST
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());
}
示例3: c
void tst_qqmlexpression::scriptString()
{
qmlRegisterType<TestObject>("Test", 1, 0, "TestObject");
QQmlEngine engine;
QQmlComponent c(&engine, testFileUrl("scriptString.qml"));
TestObject *testObj = qobject_cast<TestObject*>(c.create());
QVERIFY(testObj != 0);
QQmlScriptString script = testObj->scriptString();
QVERIFY(!script.isEmpty());
QQmlExpression expression(script);
QVariant value = expression.evaluate();
QCOMPARE(value.toInt(), 15);
QQmlScriptString scriptError = testObj->scriptStringError();
QVERIFY(!scriptError.isEmpty());
//verify that the expression has the correct error location information
QQmlExpression expressionError(scriptError);
QVariant valueError = expressionError.evaluate();
QVERIFY(!valueError.isValid());
QVERIFY(expressionError.hasError());
QQmlError error = expressionError.error();
QCOMPARE(error.url(), c.url());
QCOMPARE(error.line(), 8);
}
示例4: kTypeObjectArray
void JavaClassUtilsTest::makeNameForSignatureWithArrayOfObjects(JNIEnv *env, jobject javaThis) {
std::string result;
TestObject testObject;
JavaClassUtils::makeNameForSignature(result, kTypeObjectArray(MAKE_CANONICAL_NAME(PACKAGE, TestObject)));
std::stringstream expected;
expected << "[L" << testObject.getCanonicalName() << ";";
JUNIT_ASSERT_EQUALS_STRING(expected.str().c_str(), result);
}
示例5: makeNameForSignatureWithJniSignature
void JavaClassUtilsTest::makeNameForSignatureWithJniSignature(JNIEnv *env, jobject javaThis) {
std::string result;
TestObject testObject;
std::stringstream signature;
signature << "L" << testObject.getCanonicalName() << ";";
JavaClassUtils::makeNameForSignature(result, signature.str().c_str());
JUNIT_ASSERT_EQUALS_STRING(signature.str().c_str(), result);
}
示例6: ExperimentSingle
void ExperimentSingle(TestSetting ts) {
if (ts.getConfigBool("autoTestName")==true) {
ts.testName.insert(0,"v_single_");
cout << "(auto) testName: " << ts.testName << endl;
}
TestObject *expTest = new TestObject(ts);
expTest->runStaticTest();
delete expTest;
}
示例7: TestObject
void ObjectTest::TestAddDestroyListener()
{
TestObject* obj = new TestObject();
ObjectListener objectListener;
obj->AddDestroyListener(berry::MessageDelegate<ObjectListener>(
&objectListener, &ObjectListener::DestroyListener));
delete obj;
assertEqual(true, objectListener.m_ObjectDeleted);
}
示例8: TEUCHOS_UNIT_TEST
TEUCHOS_UNIT_TEST(global_data, accessor_default_impl)
{
Teuchos::RCP<panzer::GlobalData> gd = panzer::createGlobalData();
TestObject t;
t.setGlobalData(gd);
TestObject2 t2(gd);
TEST_EQUALITY(gd.get(), t2.getGlobalData().get());
}
示例9: 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;
}
示例10: main
int main(int argc, char* argv[])
{
/* get the NetAddr of the server */
NetAddr netAddr(argv[1]);
/* get netaddr to the proxy */
NetAddr proxy(argv[2]);
/* get size of objects */
int objectSize;
istringstream ss(argv[3]);
ss >> objectSize;
/* Initialize Server with our NetAddr */
Ginnungagap::Initialize(SERVER, 50, netAddr, netAddr);
/* Start necessary threads */
Ginnungagap::Instance()->startDataSenderThread();
Ginnungagap::Instance()->startDataAndConnectionReceiverThread();
Ginnungagap::Instance()->startMessageHandlerThread();
/* set terminal in ``any key''-mode */
struct termios oldT, newT;
ioctl(0, TCGETS, &oldT);
newT = oldT;
newT.c_lflag &= ~ECHO;
newT.c_lflag &= ~ICANON;
ioctl(0, TCSETS, &newT);
cout << "Press any key once proxy is connected" << endl;
cin.get();
cout << "Migrating objects..." << endl;
TestObject* test;
for (int i = 0; i != 10000; ++i)
{
test = new TestObject(objectSize);
Ginnungagap::Instance()->nameService()->bind(*test);
Ginnungagap::Instance()->migrationService()->migrateObject(test->objectId(), proxy);
usleep(30000);
}
cout << "Done migrating objects, press any key to exit" << endl;
cin.get();
/* restore original terminal mode */
ioctl(0, TCSETS, &oldT);
return 1;
}
示例11: main
void main()
{
// using a bit of random here.
srand(time(nullptr)); //initialize random seed based on time
// Where will this object live? Is this a good choice? Why or why not?
TestObject anObject = TestObject(30);
// Name differences between pointers and references
TestObject *anotherObject = new TestObject(2); //error: new returns a pointer-> '*'
// When should we use pointers, references and values? why?
TestObject &referenceToAnObject = anObject; //error: no &
TestObject &referenceToAnotherObject = *anotherObject; //error original adress called with '*'
TestObject* pointerToAnObject = &anObject; //error: for pointer,adress of obj. is needed with &
TestObject* pointerToAnotherObject = &referenceToAnotherObject; // error fix: for pointer, adress of Obj. is needed with '&'
// Testing if the correct strings are being printed.
referenceToAnotherObject.printAllStrings();
std::cout << "The Following should be the same as above: " << std::endl;
pointerToAnotherObject->printAllStrings();
std::cout << std::endl << "total number of strings:" << std::endl;
int& TotalElementNumber = sumTheElements(referenceToAnObject.elementCount(), referenceToAnotherObject.elementCount());
std::cout << TotalElementNumber << std::endl;
std::cout << "Do calculations in another scope and display the same value again inside that scope: " << std::endl;
{
//this isn't really doing anything, just for testing purposes
int ignoreMe = 20;
ignoreMe *= TotalElementNumber;
std::cout << TotalElementNumber << std::endl;
}
std::cout << "And again outside the scope: " << std::endl;
std::cout << TotalElementNumber << std::endl;
delete anotherObject;
//cant delete objects with stack
//delete pointerToAnObject;
//delete pointerToAnotherObject;
}
示例12: getProcess
void AgentThread::processDAEMONCLEAN_REQUEST(int socketHandle)
{
try {
ConsoleServer::debugMsg(1,"Processing DAEMONCLEAN_REQUEST\n");
// now send a signal indicating we are processing the request
Utils::sendSignal(socketHandle,RESPONSE_PROCESSING);
//clean the files now
for (int i = getProcessCount()-1; i >=0; i--) {
// check for any instance of test running with the same id
TestObject *curr = getProcess(i)->getTestObject();
if (getProcess(i)->isDaemon()) {
ConsoleServer::debugMsg(1,"Cleaning daemon %d\n",i);
// clean up the trace files
ConsoleServer::debugMsg(1,
"Cleaning environment file :%s\n",
curr->getEnvFileName().c_str());
if (Utils::delete_file(curr->getEnvFileName())!=0)
ConsoleServer::debugMsg(1,"No environment file was found :%s\n",
curr->getEnvFileName().c_str());
ConsoleServer::debugMsg(1,"Cleaning stdout file :%s\n",
curr->getStdOutFileName().c_str());
if (Utils::delete_file(curr->getStdOutFileName())!=0)
ConsoleServer::debugMsg(1,"No stdout file was found :%s\n",
curr->getStdOutFileName().c_str());
ConsoleServer::debugMsg(1,"Cleaning stderr file :%s\n",
curr->getStdErrFileName().c_str());
if (Utils::delete_file(curr->getStdErrFileName())!=0)
ConsoleServer::debugMsg(1,"No stderr file was found :%s\n",
curr->getStdErrFileName().c_str());
// remove from our list of test objects
ConsoleServer::debugMsg(1,"Removing process from process pool\n");
delProcess(i);
}
}
// now send a signal indicating we have finished
Utils::sendSignal(socketHandle,RESPONSE_FINISHED_OK);
}
catch (char * message) {
ConsoleServer::debugMsg(1,"Error processing DAEMONCLEAN_REQUEST request:%s\n",message);
Utils::sendSignal(socketHandle,RESPONSE_FINISHED_ERROR);
}
};
示例13: ExperimentVaryRange
void ExperimentVaryRange(TestSetting ts) {
if (ts.getConfigBool("autoTestName")==true) {
ts.testName.insert(0,"v_range_");
cout << "(auto) testName: " << ts.testName << endl;
}
int lowRange = ts.getConfigInt("lowRange");
int highRange = ts.getConfigInt("highRange");
for (int range = lowRange; range <= highRange ; range*=2) {
ts.range = range;
cout << "*** Now using ts.range = " << ts.range << endl;
TestObject *expTest = new TestObject(ts);
expTest->runStaticTest();
delete expTest;
}
}
示例14: ExperimentVaryCacheSize
void ExperimentVaryCacheSize(TestSetting ts) {
if (ts.getConfigBool("autoTestName")==true) {
ts.testName.insert(0,"v_cachesize_");
cout << "(auto) testName: " << ts.testName << endl;
}
unsigned long lowCacheSize = ts.getConfigLong("lowCacheSize");
unsigned long highCacheSize = ts.getConfigLong("highCacheSize");
for (unsigned long csize = lowCacheSize; csize <= highCacheSize ; csize*=2) {
ts.cacheSize = csize;
cout << "*** Now using ts.cacheSize = " << ts.cacheSize << endl;
TestObject *expTest = new TestObject(ts);
expTest->runStaticTest();
delete expTest;
}
}
示例15: ExperimentVarySplit
void ExperimentVarySplit(TestSetting ts) {
if (ts.getConfigBool("autoTestName")==true) {
ts.testName.insert(0,"v_split_");
cout << "(auto) testName: " << ts.testName << endl;
}
int lowSplit = ts.getConfigInt("lowSplit");
int highSplit = ts.getConfigInt("highSplit");
for (int splits = lowSplit; splits <= highSplit ; splits+=2) {
ts.splits = splits;
cout << "*** Now using ts.splits = " << ts.splits << endl;
TestObject *expTest = new TestObject(ts);
expTest->runStaticTest();
delete expTest;
}
}