当前位置: 首页>>代码示例>>C++>>正文


C++ TestData::GetInteger方法代码示例

本文整理汇总了C++中TestData::GetInteger方法的典型用法代码示例。如果您正苦于以下问题:C++ TestData::GetInteger方法的具体用法?C++ TestData::GetInteger怎么用?C++ TestData::GetInteger使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TestData的用法示例。


在下文中一共展示了TestData::GetInteger方法的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);
//.........这里部分代码省略.........
开发者ID:colonelqubit,项目名称:halyard,代码行数:101,代码来源:ModelTests.cpp


注:本文中的TestData::GetInteger方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。