예제 #1
0
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 "";
}
예제 #2
0
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 "";
}