本文整理汇总了C++中Map::GetString方法的典型用法代码示例。如果您正苦于以下问题:C++ Map::GetString方法的具体用法?C++ Map::GetString怎么用?C++ Map::GetString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Map
的用法示例。
在下文中一共展示了Map::GetString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_Model
void test_Model (void) {
ModelFormat format("TestData", 0, 0);
Model model(format);
TEST(model.CanUndo() == false);
TEST(model.CanRedo() == false);
TestData *root = cast<TestData>(model.GetRoot());
TEST(root);
// Test the basic value types.
root->SetInteger("testInt", 10);
TEST(root->GetInteger("testInt") == 10);
root->SetString("testString", "foo");
TEST(root->GetString("testString") == "foo");
// Test the error-checking code.
TEST_EXCEPTION(root->GetInteger("nosuch"), TException);
// Make sure that Undo is enabled.
TEST(model.CanUndo() == true);
TEST(model.CanRedo() == false);
// Test Undo by removing the "test string" key.
model.Undo();
TEST(root->GetInteger("testInt") == 10);
TEST_EXCEPTION(root->GetString("testString"), TException);
// Make sure that *both* Undo and Redo are enabled.
TEST(model.CanUndo() == true);
TEST(model.CanRedo() == true);
// Test Undo by removing the "test int" key.
model.Undo();
TEST_EXCEPTION(root->GetInteger("testInt"), TException);
TEST_EXCEPTION(root->GetString("testString"), TException);
// Make sure that only Redo is enabled.
TEST(model.CanUndo() == false);
TEST(model.CanRedo() == true);
// Test Redo.
model.Redo();
TEST(root->GetInteger("testInt") == 10);
TEST_EXCEPTION(root->GetString("testString"), TException);
TEST(model.CanUndo() == true);
TEST(model.CanRedo() == true);
model.Redo();
TEST(root->GetInteger("testInt") == 10);
TEST(root->GetString("testString") == "foo");
TEST(model.CanUndo() == true);
TEST(model.CanRedo() == false);
// Test overwriting of Redo data.
model.Undo();
TEST_EXCEPTION(root->GetString("testString"), TException);
root->SetString("testString", "bar");
TEST(model.CanUndo() == true);
TEST(model.CanRedo() == false);
TEST(root->GetString("testString") == "bar");
// Test clearing of Undo data.
model.Undo();
TEST(model.CanUndo() == true);
TEST(model.CanRedo() == true);
model.ClearUndoList();
TEST(model.CanUndo() == false);
TEST(model.CanRedo() == true);
model.Redo();
TEST(model.CanUndo() == true);
TEST(model.CanRedo() == false);
TEST(root->GetString("testString") == "bar");
//---------------------------------------------------------------------
// OK, we pretty much believe that Undo/Redo are correct. Now
// we need to test ALL the subclasses of Change.
// Insert a new map datum to work with.
root->Set("testMap", new Map());
Map *map = cast<Map>(root->Get("testMap"));
// Test CollectionDatum::SetChange on Map.
map->SetString("SetChange", "new key");
TEST(map->GetString("SetChange") == "new key");
model.Undo();
TEST_EXCEPTION(map->GetString("SetChange"), TException);
model.Redo();
TEST(map->GetString("SetChange") == "new key");
map->SetString("SetChange", "change value");
TEST(map->GetString("SetChange") == "change value");
model.Undo();
TEST(map->GetString("SetChange") == "new key");
model.Redo();
TEST(map->GetString("SetChange") == "change value");
// Test CollectionDatum::DeleteChange on Map.
TEST_EXCEPTION(map->Delete("nosuch"), TException);
map->SetString("DeleteChange", "foo");
TEST(map->GetString("DeleteChange") == "foo");
map->Delete("DeleteChange");
TEST_EXCEPTION(map->Delete("DeleteChange"), TException);
//.........这里部分代码省略.........