本文整理汇总了C++中ConfigManager::setConfig方法的典型用法代码示例。如果您正苦于以下问题:C++ ConfigManager::setConfig方法的具体用法?C++ ConfigManager::setConfig怎么用?C++ ConfigManager::setConfig使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConfigManager
的用法示例。
在下文中一共展示了ConfigManager::setConfig方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
//.........这里部分代码省略.........