コード例 #1
0
ファイル: LoadTests.cpp プロジェクト: Andresbu/Envision
TEST(FilePersistence, LoadMultipleUnits)
{
	QString testDir = ":/FilePersistence/test/persisted";
	Model::Model model;
	FileStore store;
	store.setBaseFolder(testDir);

	model.load(&store, "units");
	TestNodes::BinaryNode* root = dynamic_cast<TestNodes::BinaryNode*> (model.root());

	CHECK_STR_EQUAL("BinaryNode", root->typeName() );
	CHECK_STR_EQUAL("Root", root->name()->get() );
	CHECK_CONDITION(root->left() != nullptr);
	CHECK_CONDITION(root->right() != nullptr);
	CHECK_STR_EQUAL("BinaryNodePersistenceUnit", root->left()->typeName() );
	CHECK_STR_EQUAL("Left child", root->left()->name()->get() );
	CHECK_CONDITION(root->left()->left() != nullptr);
	CHECK_CONDITION(root->left()->right() == nullptr);
	CHECK_STR_EQUAL("BinaryNode", root->left()->left()->typeName() );
	CHECK_STR_EQUAL("in a new unit", root->left()->left()->name()->get() );
	CHECK_CONDITION(root->left()->left()->left() == nullptr);
	CHECK_CONDITION(root->left()->left()->right() == nullptr);
	CHECK_STR_EQUAL("BinaryNode", root->right()->typeName() );
	CHECK_STR_EQUAL("Right child", root->right()->name()->get() );
	CHECK_CONDITION(root->right()->left() == nullptr);
	CHECK_CONDITION(root->right()->right() == nullptr);
}
コード例 #2
0
ファイル: LoadTests.cpp プロジェクト: Andresbu/Envision
TEST(FilePersistence, LoadRootOnly)
{
	QString testDir = ":/FilePersistence/test/persisted";
	Model::Model model;
	FileStore store;
	store.setBaseFolder(testDir);

	model.load(&store, "rootOnly");
	TestNodes::BinaryNode* root = dynamic_cast<TestNodes::BinaryNode*> (model.root());

	CHECK_CONDITION(root);
	CHECK_STR_EQUAL("BinaryNode", root->typeName() );
	CHECK_STR_EQUAL("Title", root->name()->get() );
	CHECK_CONDITION(root->left() == nullptr);
	CHECK_CONDITION(root->right() == nullptr);
}