/* **************************************************************************** * * main - */ int main(int argC, char** argV) { paConfig("usage and exit on any warning", (void*) true); paConfig("log to screen", (void*) "only errors"); paConfig("log file line format", (void*) "TYPE:DATE:EXEC-AUX/FILE[LINE](p.PID)(t.TID) FUNC: TEXT"); paConfig("screen line format", (void*) "TYPE@TIME EXEC: TEXT"); paConfig("log to file", (void*) true); paConfig("default value", "-logDir", (void*) "/tmp"); paConfig("man author", "Fermín Galán and Ken Zangelin"); if (argC > 1) { if (strcmp(argV[1], "-t") == 0) paParse(paArgs, 3, argV, 3, false); else paParse(paArgs, 1, argV, 1, false); } else paParse(paArgs, 1, argV, 1, false); LM_M(("Init tests")); orionInit(exitFunction, orionUnitTestVersion, SemReadWriteOp, false); setupDatabase(); LM_M(("Run all tests")); ::testing::InitGoogleMock(&argC, argV); return RUN_ALL_TESTS(); }
/* **************************************************************************** * * child - */ void* child(void* vP) { int childNo = *((int*) vP); for (int ix = 0; ix < 1000; ix++) LM_M(("Child %d: M%d", childNo, ix)); return (void*) 0; }
/* **************************************************************************** * * check_json - */ TEST(ContextAttributeResponse, check_json) { ContextAttribute ca("caName", "caType", "caValue"); ContextAttributeResponse car; std::string out; const char* outfile1 = "ngsi10.contextAttributeResponse.check3.valid.json"; const char* outfile2 = "ngsi10.contextAttributeResponse.check4.valid.json"; ConnectionInfo ci; utInit(); // 1. OK car.contextAttributeVector.push_back(&ca); car.statusCode.fill(SccOk, "OK"); ci.outFormat = JSON; out = car.check(&ci, UpdateContextAttribute, "", "", 0); EXPECT_STREQ("OK", out.c_str()); // 2. predetectedError out = car.check(&ci, UpdateContextAttribute, "", "PRE Error", 0); EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), outfile1)) << "Error getting test data from '" << outfile1 << "'"; EXPECT_STREQ(expectedBuf, out.c_str()); // 3. Bad ContextAttribute ContextAttribute ca2("", "caType", "caValue"); car.contextAttributeVector.push_back(&ca2); LM_M(("car.contextAttributeVector.size: %d - calling ContextAttributeResponse::check", car.contextAttributeVector.size())); out = car.check(&ci, UpdateContextAttribute, "", "", 0); EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), outfile2)) << "Error getting test data from '" << outfile2 << "'"; EXPECT_STREQ(expectedBuf, out.c_str()); utExit(); }