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


C++ Folder::addFile方法代码示例

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


在下文中一共展示了Folder::addFile方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: virusTest

string virusTest()
{
	vector<File*> fls;
	Folder * f = new Folder("test");
	
	File * file = new File();
	
	Virus * v = new Virus();
	v->type = Virus::CREATING;
	v->nextHarm = 0;
	file->setVirus(v);
	
	f->addFile(file);
	
	f->getAllFilesRecursively(fls);
	if(fls.size() != 1) return "file count mismatch 1";
	
	v->update(f);
	
	fls.clear();
	f->getAllFilesRecursively(fls);
	if(fls.size() != 2) return "file count mismatch 2";
	
	v->type = Virus::ERASING;
	v->nextHarm = 0;
	v->update(f);
	
	fls.clear();
	f->getAllFilesRecursively(fls);
	if(fls.size() != 2) return "file count mismatch 3";
	
	delete f;
	
	return "";
}
开发者ID:FITdatagame,项目名称:DataGame,代码行数:35,代码来源:tests.cpp

示例2: folderTest

string folderTest()
{
	vector<pair<Folder *, int>> folds;
	vector<File*> fls;
	Folder * f = new Folder("test");
	
	f->getAllFoldersRecursively(folds);
	if(folds.size() > 1) return "found folders in empty folder";
	
	f->getAllFilesRecursively(fls);
	if(fls.size()) return "files found in empty folder";
	
	File * file = new File();
	f->addFile(file);
	
	fls.clear();
	f->getAllFilesRecursively(fls);
	if(fls.size() != 1) return "file count mismatch";
	if(f->getSize() != file->getSize()) return "file size mismatch";
	
	Folder * f2 = new Folder("test2");
	if(!f->addFolder(f2)) return "addfolder failed";
	
	folds.clear();
	f->getAllFoldersRecursively(folds);
	if(folds.size() != 2) return "folder count mismatch";
	
	File * file2 = new File();
	f2->addFile(file2);
	
	fls.clear();
	f->getAllFilesRecursively(fls);
	if(fls.size() != 2) return "file count mismatch2";
	if(f->getSize() != file->getSize() + file2->getSize()) return "file size mismatch2";
	
	f->removeFile(file->getName());
	delete file;
	
	fls.clear();
	f->getAllFilesRecursively(fls);
	if(fls.size() != 1) return "file count mismatch3";
	if(f->getSize() != file2->getSize()) return "file size mismatch3";
	
	f->removeFolder(f2->getName());
	delete f2;
	
	folds.clear();
	f->getAllFoldersRecursively(folds);
	if(folds.size() != 1) return "folder count mismatch2";
	
	delete f;

	return "";
}
开发者ID:FITdatagame,项目名称:DataGame,代码行数:54,代码来源:tests.cpp

示例3: antivirusManagerTest

string antivirusManagerTest()
{
	AntivirusManager * am = new AntivirusManager();
	
	Folder * folder = new Folder("test");
	File * regular = new File();
	File * infected = new File();
	Virus * virus = new Virus();
	
	infected->setVirus(virus);
	
	folder->addFile(regular);
	folder->addFile(infected);
	
	am->processFolder(folder);
	
	if(!infected->getVirusState().discovered || regular->getVirusState().discovered)
		return "virus detection failed";
	
	delete folder;
	delete am;

	return "";
}
开发者ID:FITdatagame,项目名称:DataGame,代码行数:24,代码来源:tests.cpp


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