本文整理汇总了C++中TestRunner::passIfException方法的典型用法代码示例。如果您正苦于以下问题:C++ TestRunner::passIfException方法的具体用法?C++ TestRunner::passIfException怎么用?C++ TestRunner::passIfException使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TestRunner
的用法示例。
在下文中一共展示了TestRunner::passIfException方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: runHttpClientRedirectLoopTest
static void runHttpClientRedirectLoopTest(TestRunner& tr)
{
tr.test("Http Client Redirect Loop");
// start a kernel
Kernel k;
k.getEngine()->start();
// create server
Server server;
InternetAddress address("0.0.0.0", 19123);
// create SSL/generic http connection servicer
HttpConnectionServicer hcs;
server.addConnectionService(&address, &hcs);
// create redirect loop http request servicer
RedirectLoopHttpRequestServicer loop("/loop");
hcs.addRequestServicer(&loop, false);
if(server.start(&k))
{
printf("\nServer started on %s\n",
address.toString(false).c_str());
// create client
HttpClient client;
printf("Connecting and expecting a redirect loop...\n");
// do get
Url url("http://localhost:19123/loop");
HttpResponse* response = client.get(&url, NULL, 2);
if(response != NULL)
{
printf("Response=\n%s\n", response->getHeader()->toString().c_str());
}
else
{
printf("Correctly detected an exception:\n");
printf("'%s'\n", Exception::get()->getMessage());
}
client.disconnect();
}
else if(Exception::get() != NULL)
{
printf("\nServer start failed with errors=%s\n",
Exception::get()->getMessage());
}
tr.passIfException();
// stop server and kernel
server.stop();
k.getEngine()->stop();
Exception::clear();
}
示例2: mediaGetTest
static void mediaGetTest(Node& node, TestRunner& tr)
{
tr.group("media");
Messenger* messenger = node.getMessenger();
tr.test("get");
{
// create url for obtaining media
Url url("/api/3.0/media/2");
// get media
Media media;
assertNoException(
messenger->getFromBitmunk(&url, media));
printf("\nMedia:\n");
dumpDynamicObject(media, false);
}
tr.passIfNoException();
tr.test("invalid get");
{
// create url for obtaining media
Url url("/api/3.0/media/invalidMediaId");
// get media
Media media;
messenger->getFromBitmunk(&url, media);
}
tr.passIfException();
tr.test("all");
{
// create url for getting media
Url url("/api/3.0/media/?start=0&num=5");
// get results
DynamicObject results;
//assertNoException(
// messenger->getFromBitmunk(&url, results));
printf("\nDISABLED FOR PERFORMANCE\n");
/*
printf("\nGetting 5 media starting at #0\n(of %" PRIu32 " found)\n",
results["total"]->getUInt32());
dumpDynamicObject(results, false);
*/
}
tr.passIfNoException();
tr.test("owned");
{
// create url for searching media
Url url("/api/3.0/media?owner=900");
// get results
DynamicObject results;
assertNoException(
messenger->getFromBitmunk(&url, results));
printf("\nMedia owned by user 900\n");
printf("Results %" PRIu32 "-%" PRIu32 " of %" PRIu32 "\n",
results["start"]->getUInt32(),
results["start"]->getUInt32() + results["num"]->getUInt32(),
results["total"]->getUInt32());
dumpDynamicObject(results, false);
}
tr.passIfNoException();
tr.test("search");
{
// create url for searching media
Url url("/api/3.0/media/?query=test&start=0&num=10");
// get results
DynamicObject results;
assertNoException(
messenger->getFromBitmunk(&url, results));
printf("\nSearching media & contributors for 'test'\n");
printf("Results %" PRIu32 "-%" PRIu32 " of %" PRIu32 "\n",
results["start"]->getUInt32(),
results["start"]->getUInt32() + results["num"]->getUInt32(),
results["total"]->getUInt32());
dumpDynamicObject(results, false);
}
tr.passIfNoException();
tr.test("genre media");
{
// create url for searching media
Url url("/api/3.0/media?type=audio&genre=165&start=4&num=5");
// get results
DynamicObject results;
assertNoException(
messenger->getFromBitmunk(&url, results));
printf("\nAudio from genre 165\n");
//.........这里部分代码省略.........
示例3: runConfigManagerTest
static void runConfigManagerTest(TestRunner& tr)
{
tr.group("ConfigManager");
tr.test("init");
{
DynamicObject expect;
expect->setType(Map);
ConfigManager cm;
Config cfg;
cfg[ConfigManager::ID] = "config";
cfg[ConfigManager::MERGE]->setType(Map);
assert(cm.addConfig(cfg));
assertDynoCmp(cm.getConfig("config", true), cfg);
assertDynoCmp(cm.getConfig("config", false), expect);
assertDynoCmp(cm.getConfig("config"), expect);
}
tr.passIfNoException();
tr.test("init & clear");
{
DynamicObject expect;
expect->setType(Map);
ConfigManager cm;
Config cfg;
cfg[ConfigManager::ID] = "config";
cfg[ConfigManager::MERGE]->setType(Map);
assert(cm.addConfig(cfg));
cm.clear();
Config cfg2 = cm.getConfig("config");
assert(cfg2.isNull());
}
tr.passIfException();
tr.test("1 config");
{
DynamicObject expect;
expect->setType(Map);
expect["a"] = 0;
ConfigManager cm;
Config cfg;
cfg[ConfigManager::ID] = "config";
cfg[ConfigManager::MERGE]["a"] = 0;
assert(cm.addConfig(cfg));
assertNoExceptionSet();
assertDynoCmp(cm.getConfig("config"), expect);
}
tr.passIfNoException();
tr.test("config change");
{
ConfigManager cm;
Config cfg;
cfg[ConfigManager::ID] = "config";
cfg[ConfigManager::MERGE]["a"] = 0;
assert(cm.addConfig(cfg));
DynamicObject a;
a["a"] = 0;
assertDynoCmp(cm.getConfig("config"), a);
Config change = cm.getConfig("config", true);
change[ConfigManager::MERGE]["a"] = 1;
assert(cm.setConfig(change));
DynamicObject expect;
expect["a"] = 1;
assert(cm.getConfig("config") != a);
assertDynoCmp(cm.getConfig("config"), expect);
}
tr.passIfNoException();
tr.test("invalid set config");
{
ConfigManager cm;
Config cfg;
cfg[ConfigManager::ID] = "config";
cfg[ConfigManager::MERGE]["a"] = 0;
assert(!cm.setConfig(cfg));
}
tr.passIfException();
tr.test("double add config");
{
ConfigManager cm;
Config cfg;
cfg[ConfigManager::ID] = "config";
cfg[ConfigManager::MERGE]["a"] = 0;
assert(cm.addConfig(cfg));
cfg[ConfigManager::MERGE]["a"] = 1;
assert(cm.addConfig(cfg));
DynamicObject expect;
expect["a"] = 1;
assertDynoCmp(cm.getConfig("config"), expect);
}
tr.passIfNoException();
tr.test("add");
{
DynamicObject expect;
expect["a"] = 0;
expect["b"] = 1;
expect["c"] = 2;
//.........这里部分代码省略.........
示例4: customCatalogTests
//.........这里部分代码省略.........
out["description"] = "Payee scheme description 2";
Payee p1 = out["payees"]->append();
Payee p2 = out["payees"]->append();
p1["id"] = 900;
p1["amountType"] = PAYEE_AMOUNT_TYPE_FLATFEE;
p1["amount"] = "0.15";
p1["description"] = "test-services-customcatalog test payee 1 (updated)";
p2["id"] = 900;
p2["amountType"] = PAYEE_AMOUNT_TYPE_PTOTAL;
p2["percentage"] = "0.14";
p2["description"] = "test-services-customcatalog test payee 2 (updated)";
// update a pre-existing payee scheme
assertNoException(
messenger->post(
&payeeSchemeIdUrl, &out, &in, node.getDefaultUserId()));
// ensure that the payee scheme was updated
assert(in["payeeSchemeId"]->getUInt32() == 2);
if(in->hasMember("payeeSchemeId"))
{
psId = in["payeeSchemeId"]->getUInt32();
}
}
tr.passIfNoException();
tr.test("add ware with payee scheme (valid)");
{
DynamicObject in;
DynamicObject out;
// create the outgoing ware object
FileInfo fi;
fi["id"] = TEST_FILE_ID_2;
out["id"] = TEST_WARE_ID_2;
out["mediaId"] = 2;
out["description"] = "This ware was added by test-services-customcatalog";
out["fileInfo"] = fi;
out["payeeSchemeId"] = psId;
// add the ware to the custom catalog
messenger->post(&waresUrl, &out, &in, node.getDefaultUserId());
}
tr.passIfNoException();
tr.test("remove associated payee scheme (invalid)");
{
messenger->deleteResource(
&payeeSchemeIdUrl, NULL, node.getDefaultUserId());
}
tr.passIfException();
tr.test("remove ware associated w/ payee scheme (valid)");
{
messenger->deleteResource(
&wareUrl, NULL, node.getDefaultUserId());
}
tr.passIfNoException();
tr.test("remove payee scheme (valid)");
{
messenger->deleteResource(
&payeeSchemeIdUrl, NULL, node.getDefaultUserId());
}
tr.passIfNoException();
tr.test("create ware w/ invalid payee scheme (invalid)");
{
DynamicObject in;
DynamicObject out;
// create the outgoing ware object
FileInfo fi;
fi["id"] = TEST_FILE_ID_2;
PayeeScheme ps;
ps["id"] = psId;
out["id"] = TEST_WARE_ID_2;
out["mediaId"] = 2;
out["description"] = "This ware was added by test-services-customcatalog";
out["fileInfo"] = fi;
out["payeeScheme"] = ps;
// add the ware to the custom catalog
messenger->post(&waresUrl, &out, &in, node.getDefaultUserId());
}
tr.passIfException();
tr.test("remove ware (invalid)");
{
// remove a ware that doesn't exist
messenger->deleteResource(&wareUrl, NULL, node.getDefaultUserId());
}
tr.passIfException();
tr.ungroup();
}