void TestFileUtilNaming(void)
{
	CFileUtil	cFileUtil;
	CChars		sz;
	CChars		szExpected;

	sz.Init();
	cFileUtil.FullPath(&sz);
	sz.LowerCase();
	szExpected.Init("C:\\GameEngine\\Test\\TestBaseLib\\TestBaseLib");
	szExpected.LowerCase();
	AssertString(szExpected.Text(), sz.Text());
	szExpected.Kill();
	sz.Kill();

	sz.Init("c:\\Documents and Settings\\Joe\\..\\..\\");
	cFileUtil.CollapsePath(&sz);
	AssertStringCase("C:\\", sz.Text(), FALSE);
	sz.Kill();

	sz.Init("\\Documents\\and\\Settings\\..\\..\\Joe");
	cFileUtil.CollapsePath(&sz);
	AssertString("\\Documents\\Joe", sz.Text());
	sz.Kill();

	sz.Init("\\Documents\\and\\Settings\\..\\..\\Joe\\");
	cFileUtil.CollapsePath(&sz);
	AssertString("\\Documents\\Joe", sz.Text());
	sz.Kill();

	sz.Init(".\\.\\.\\.");
	cFileUtil.CollapsePath(&sz);
	AssertString("", sz.Text());
	sz.Kill();

	sz.Init(".\\.\\.\\");
	cFileUtil.CollapsePath(&sz);
	AssertString("", sz.Text());
	sz.Kill();

	sz.Init("c:\\..");
	cFileUtil.CollapsePath(&sz);
	AssertString("c:", sz.Text());
	sz.Kill();

	sz.Init("c:\\..\\..");
	cFileUtil.CollapsePath(&sz);
	AssertString("c:", sz.Text());
	sz.Kill();

	sz.Init("\\..\\..");
	cFileUtil.CollapsePath(&sz);
	AssertString("", sz.Text());
	sz.Kill();
}
Beispiel #2
0
void TestFileSystemFindExtension(void)
{
	CFileSystem				cSystem;
	CArraySystemFilePtrs	aFileNodePtrs;

	cSystem.Init("Finder");

	aFileNodePtrs.Init(8);
	cSystem.GetFiles(&aFileNodePtrs, "rar");

	AssertInt(6, aFileNodePtrs.NumElements());

	AssertStringCase("C:\\gameengine\\Test\\TestBaseLib\\TestBaseLib\\Finder\\Lord\\1.rar", (*aFileNodePtrs.Get(0))->File()->GetFullName(), FALSE);
	AssertStringCase("C:\\gameengine\\Test\\TestBaseLib\\TestBaseLib\\Finder\\Rising\\2.rar", (*aFileNodePtrs.Get(1))->File()->GetFullName(), FALSE);
	AssertStringCase("C:\\gameengine\\Test\\TestBaseLib\\TestBaseLib\\Finder\\Storm\\3.rar", (*aFileNodePtrs.Get(2))->File()->GetFullName(), FALSE);
	AssertStringCase("C:\\gameengine\\Test\\TestBaseLib\\TestBaseLib\\Finder\\Ants.rar", (*aFileNodePtrs.Get(3))->File()->GetFullName(), FALSE);
	AssertStringCase("C:\\gameengine\\Test\\TestBaseLib\\TestBaseLib\\Finder\\Echo.rar", (*aFileNodePtrs.Get(4))->File()->GetFullName(), FALSE);
	AssertStringCase("C:\\gameengine\\Test\\TestBaseLib\\TestBaseLib\\Finder\\March.rar", (*aFileNodePtrs.Get(5))->File()->GetFullName(), FALSE);

	aFileNodePtrs.Kill();
	cSystem.Kill();
}
void TestFileFinder(void)
{
	BeginTests();

	CFileUtil		cFileUtil;
	CArrayString	aszFiles;

	aszFiles.Init(1);
	cFileUtil.FindFilesWithExtension("Finder", "txt", &aszFiles);
	AssertInt(5, aszFiles.NumElements());
	AssertStringCase("C:\\gameengine\\Test\\TestBaseLib\\TestBaseLib\\Finder\\Ants.txt", aszFiles.Get(0)->Text(), FALSE);
	AssertStringCase("C:\\gameengine\\Test\\TestBaseLib\\TestBaseLib\\Finder\\File.txt", aszFiles.Get(1)->Text(), FALSE);
	AssertStringCase("C:\\gameengine\\Test\\TestBaseLib\\TestBaseLib\\Finder\\Last.txt", aszFiles.Get(2)->Text(), FALSE);
	AssertStringCase("C:\\gameengine\\Test\\TestBaseLib\\TestBaseLib\\Finder\\Marching.txt", aszFiles.Get(3)->Text(), FALSE);
	AssertStringCase("C:\\gameengine\\Test\\TestBaseLib\\TestBaseLib\\Finder\\Ninja.txt", aszFiles.Get(4)->Text(), FALSE);
	aszFiles.Kill();

	aszFiles.Init(1);
	cFileUtil.FindFilesWithNameContaining("Finder", "Mar", &aszFiles);
	AssertInt(3, aszFiles.NumElements());
	AssertStringCase("C:\\gameengine\\Test\\TestBaseLib\\TestBaseLib\\Finder\\Glenmark.wav", aszFiles.Get(0)->Text(), FALSE);
	AssertStringCase("C:\\gameengine\\Test\\TestBaseLib\\TestBaseLib\\Finder\\March.rar", aszFiles.Get(1)->Text(), FALSE);
	AssertStringCase("C:\\gameengine\\Test\\TestBaseLib\\TestBaseLib\\Finder\\Marching.txt", aszFiles.Get(2)->Text(), FALSE);
	aszFiles.Kill();

	aszFiles.Init(1);
	cFileUtil.FindAllDirectories("Finder", &aszFiles);
	aszFiles.QuickSort();
	AssertInt(5, aszFiles.NumElements());
	AssertStringCase("C:\\gameengine\\Test\\TestBaseLib\\TestBaseLib\\Finder\\.", aszFiles.Get(0)->Text(), FALSE);
	AssertStringCase("C:\\gameengine\\Test\\TestBaseLib\\TestBaseLib\\Finder\\..", aszFiles.Get(1)->Text(), FALSE);
	AssertStringCase("C:\\gameengine\\Test\\TestBaseLib\\TestBaseLib\\Finder\\Lord", aszFiles.Get(2)->Text(), FALSE);
	AssertStringCase("C:\\gameengine\\Test\\TestBaseLib\\TestBaseLib\\Finder\\Rising", aszFiles.Get(3)->Text(), FALSE);
	AssertStringCase("C:\\gameengine\\Test\\TestBaseLib\\TestBaseLib\\Finder\\Storm", aszFiles.Get(4)->Text(), FALSE);
	aszFiles.Kill();

	aszFiles.Init(1);
	cFileUtil.FindFilesWithExtension("Finder", "rar", &aszFiles, TRUE);
	AssertInt(6, aszFiles.NumElements());
	AssertStringCase("C:\\gameengine\\Test\\TestBaseLib\\TestBaseLib\\Finder\\Lord\\1.rar", aszFiles.Get(0)->Text(), FALSE);
	AssertStringCase("C:\\gameengine\\Test\\TestBaseLib\\TestBaseLib\\Finder\\Rising\\2.rar", aszFiles.Get(1)->Text(), FALSE);
	AssertStringCase("C:\\gameengine\\Test\\TestBaseLib\\TestBaseLib\\Finder\\Storm\\3.rar", aszFiles.Get(2)->Text(), FALSE);
	AssertStringCase("C:\\gameengine\\Test\\TestBaseLib\\TestBaseLib\\Finder\\Ants.rar", aszFiles.Get(3)->Text(), FALSE);
	AssertStringCase("C:\\gameengine\\Test\\TestBaseLib\\TestBaseLib\\Finder\\Echo.rar", aszFiles.Get(4)->Text(), FALSE);
	AssertStringCase("C:\\gameengine\\Test\\TestBaseLib\\TestBaseLib\\Finder\\March.rar", aszFiles.Get(5)->Text(), FALSE);
	aszFiles.Kill();

	aszFiles.Init(1);
	cFileUtil.FindAllFiles("Finder", &aszFiles, TRUE);
	AssertInt(12, aszFiles.NumElements());
	aszFiles.Kill();

	TestStatistics();
}
Beispiel #4
0
void TestFileSystemIterator(void)
{
	CFileSystem			cSystem;
	CFileSystemIterator	cIter;

	cSystem.Init("Finder");

	AssertStringCase("C:\\gameengine\\Test\\TestBaseLib\\TestBaseLib\\Finder\\Lord\\1.rar", cSystem.StartIteration(&cIter)->File()->GetFullName(), FALSE);
	AssertStringCase("C:\\gameengine\\Test\\TestBaseLib\\TestBaseLib\\Finder\\Rising\\2.rar", cSystem.Iterate(&cIter)->File()->GetFullName(), FALSE);
	AssertStringCase("C:\\gameengine\\Test\\TestBaseLib\\TestBaseLib\\Finder\\Storm\\3.rar", cSystem.Iterate(&cIter)->File()->GetFullName(), FALSE);
	AssertStringCase("C:\\gameengine\\Test\\TestBaseLib\\TestBaseLib\\Finder\\Ants.rar", cSystem.Iterate(&cIter)->File()->GetFullName(), FALSE);
	AssertStringCase("C:\\gameengine\\Test\\TestBaseLib\\TestBaseLib\\Finder\\Ants.txt", cSystem.Iterate(&cIter)->File()->GetFullName(), FALSE);
	AssertStringCase("C:\\gameengine\\Test\\TestBaseLib\\TestBaseLib\\Finder\\Echo.rar", cSystem.Iterate(&cIter)->File()->GetFullName(), FALSE);
	AssertStringCase("C:\\gameengine\\Test\\TestBaseLib\\TestBaseLib\\Finder\\File.txt", cSystem.Iterate(&cIter)->File()->GetFullName(), FALSE);
	AssertStringCase("C:\\gameengine\\Test\\TestBaseLib\\TestBaseLib\\Finder\\Glenmark.wav", cSystem.Iterate(&cIter)->File()->GetFullName(), FALSE);
	AssertStringCase("C:\\gameengine\\Test\\TestBaseLib\\TestBaseLib\\Finder\\Last.txt", cSystem.Iterate(&cIter)->File()->GetFullName(), FALSE);
	AssertStringCase("C:\\gameengine\\Test\\TestBaseLib\\TestBaseLib\\Finder\\March.rar", cSystem.Iterate(&cIter)->File()->GetFullName(), FALSE);
	AssertStringCase("C:\\gameengine\\Test\\TestBaseLib\\TestBaseLib\\Finder\\Marching.txt", cSystem.Iterate(&cIter)->File()->GetFullName(), FALSE);
	AssertStringCase("C:\\gameengine\\Test\\TestBaseLib\\TestBaseLib\\Finder\\Ninja.txt", cSystem.Iterate(&cIter)->File()->GetFullName(), FALSE);
	AssertNull(cSystem.Iterate(&cIter));
	cSystem.StopIteration(&cIter);

	cSystem.Kill();
}
Beispiel #5
0
void TestFileSystemGetFiles(void)
{
	CFileSystem							cSystem;
	CArraySystemFilePtrs				cArrayFiles;

	cSystem.Init("Finder");
	cArrayFiles.Init(1);

	cSystem.GetFiles(&cArrayFiles);

	AssertInt(12, cArrayFiles.NumElements());

	AssertStringCase("C:\\gameengine\\Test\\TestBaseLib\\TestBaseLib\\Finder\\Lord\\1.rar", (*cArrayFiles.Get(0))->File()->GetFullName(), FALSE);
	AssertStringCase("C:\\gameengine\\Test\\TestBaseLib\\TestBaseLib\\Finder\\Rising\\2.rar", (*cArrayFiles.Get(1))->File()->GetFullName(), FALSE);
	AssertStringCase("C:\\gameengine\\Test\\TestBaseLib\\TestBaseLib\\Finder\\Storm\\3.rar", (*cArrayFiles.Get(2))->File()->GetFullName(), FALSE);
	AssertStringCase("C:\\gameengine\\Test\\TestBaseLib\\TestBaseLib\\Finder\\Ants.rar", (*cArrayFiles.Get(3))->File()->GetFullName(), FALSE);
	AssertStringCase("C:\\gameengine\\Test\\TestBaseLib\\TestBaseLib\\Finder\\Ants.txt", (*cArrayFiles.Get(4))->File()->GetFullName(), FALSE);
	AssertStringCase("C:\\gameengine\\Test\\TestBaseLib\\TestBaseLib\\Finder\\Echo.rar", (*cArrayFiles.Get(5))->File()->GetFullName(), FALSE);
	AssertStringCase("C:\\gameengine\\Test\\TestBaseLib\\TestBaseLib\\Finder\\File.txt", (*cArrayFiles.Get(6))->File()->GetFullName(), FALSE);
	AssertStringCase("C:\\gameengine\\Test\\TestBaseLib\\TestBaseLib\\Finder\\Glenmark.wav", (*cArrayFiles.Get(7))->File()->GetFullName(), FALSE);
	AssertStringCase("C:\\gameengine\\Test\\TestBaseLib\\TestBaseLib\\Finder\\Last.txt", (*cArrayFiles.Get(8))->File()->GetFullName(), FALSE);
	AssertStringCase("C:\\gameengine\\Test\\TestBaseLib\\TestBaseLib\\Finder\\March.rar", (*cArrayFiles.Get(9))->File()->GetFullName(), FALSE);
	AssertStringCase("C:\\gameengine\\Test\\TestBaseLib\\TestBaseLib\\Finder\\Marching.txt", (*cArrayFiles.Get(10))->File()->GetFullName(), FALSE);
	AssertStringCase("C:\\gameengine\\Test\\TestBaseLib\\TestBaseLib\\Finder\\Ninja.txt", (*cArrayFiles.Get(11))->File()->GetFullName(), FALSE);

	cArrayFiles.Kill();
	cSystem.Kill();
}
void TestFilesIteration(void)
{
	CFiles			cFiles;
	CFileIterator	cIter;

	cFiles.Init("Game", "PAK");
	AssertInt(6, cFiles.GetNumPackFiles());
	AssertString("C:\\gameengine\\Test\\TestCoreLib\\TestCoreLib\\Game\\Sounds\\Cheese.PAK", cFiles.GetPackFiles(0)->GetFileName());
	AssertString("C:\\gameengine\\Test\\TestCoreLib\\TestCoreLib\\Game\\Sounds\\Santa.PAK", cFiles.GetPackFiles(1)->GetFileName());
	AssertString("C:\\gameengine\\Test\\TestCoreLib\\TestCoreLib\\Game\\Textures.PAK", cFiles.GetPackFiles(2)->GetFileName());
	AssertString("C:\\gameengine\\Test\\TestCoreLib\\TestCoreLib\\Game\\Models.PAK", cFiles.GetPackFiles(3)->GetFileName());
	AssertString("C:\\gameengine\\Test\\TestCoreLib\\TestCoreLib\\Game\\Sounds.PAK", cFiles.GetPackFiles(4)->GetFileName());
	AssertString("C:\\gameengine\\Test\\TestCoreLib\\TestCoreLib\\Game\\Videos.PAK", cFiles.GetPackFiles(5)->GetFileName());

	AssertStringCase("Sounds/Cheese/Moose.txt", cFiles.StartIteration(&cIter)->GetFullName(), FALSE);
	AssertInt(1, cIter.GetCurrent()->GetFileRank());
	AssertInt(FIRT_PackFiles, cIter.GetCurrent()->GetType());

	AssertStringCase("Sounds/Cheese/Scream.txt", cFiles.Iterate(&cIter)->GetFullName(), FALSE); 
	AssertInt(1, cIter.GetCurrent()->GetFileRank());
	AssertInt(FIRT_PackFiles, cIter.GetCurrent()->GetType());

	AssertStringCase("Sounds/Santa/Slay/Spelling.txt", cFiles.Iterate(&cIter)->GetFullName(), FALSE); 
	AssertInt(1, cIter.GetCurrent()->GetFileRank());
	AssertInt(FIRT_PackFiles, cIter.GetCurrent()->GetType());

	AssertStringCase("Sounds/Santa/Seattle.txt", cFiles.Iterate(&cIter)->GetFullName(), FALSE); 
	AssertInt(1, cIter.GetCurrent()->GetFileRank());
	AssertInt(FIRT_PackFiles, cIter.GetCurrent()->GetType());

	AssertStringCase("Models/Super/Barbie.txt", cFiles.Iterate(&cIter)->GetFullName(), FALSE); 
	AssertInt(0, cIter.GetCurrent()->GetFileRank());
	AssertInt(FIRT_PackFiles, cIter.GetCurrent()->GetType());

	AssertStringCase("Models/Super/Ken.txt", cFiles.Iterate(&cIter)->GetFullName(), FALSE); 
	AssertInt(0, cIter.GetCurrent()->GetFileRank());
	AssertInt(FIRT_PackFiles, cIter.GetCurrent()->GetType());

	AssertStringCase("Models/Cars.txt", cFiles.Iterate(&cIter)->GetFullName(), FALSE); 
	AssertInt(0, cIter.GetCurrent()->GetFileRank());
	AssertInt(FIRT_PackFiles, cIter.GetCurrent()->GetType());

	AssertStringCase("Sounds/Cheese/Moose.txt", cFiles.Iterate(&cIter)->GetFullName(), FALSE); 
	AssertInt(0, cIter.GetCurrent()->GetFileRank());
	AssertInt(FIRT_PackFiles, cIter.GetCurrent()->GetType());

	AssertStringCase("Sounds/Cheese/Scream.txt", cFiles.Iterate(&cIter)->GetFullName(), FALSE); 
	AssertInt(0, cIter.GetCurrent()->GetFileRank());
	AssertInt(FIRT_PackFiles, cIter.GetCurrent()->GetType());

	AssertStringCase("Sounds/Santa/Seattle.txt", cFiles.Iterate(&cIter)->GetFullName(), FALSE); 
	AssertInt(0, cIter.GetCurrent()->GetFileRank());
	AssertInt(FIRT_PackFiles, cIter.GetCurrent()->GetType());

	AssertStringCase("Sounds/Ambient.txt", cFiles.Iterate(&cIter)->GetFullName(), FALSE); 
	AssertInt(0, cIter.GetCurrent()->GetFileRank());
	AssertInt(FIRT_PackFiles, cIter.GetCurrent()->GetType());

	AssertStringCase("Sounds/General.txt", cFiles.Iterate(&cIter)->GetFullName(), FALSE); 
	AssertInt(0, cIter.GetCurrent()->GetFileRank());
	AssertInt(FIRT_PackFiles, cIter.GetCurrent()->GetType());

	AssertStringCase("Videos/Intro.txt", cFiles.Iterate(&cIter)->GetFullName(), FALSE); 
	AssertInt(0, cIter.GetCurrent()->GetFileRank());
	AssertInt(FIRT_PackFiles, cIter.GetCurrent()->GetType());

	AssertStringCase("Models/Super/Barbie.txt", cFiles.Iterate(&cIter)->GetFullName(), FALSE); 
	AssertInt(FILE_SYSTEM_RANK, cIter.GetCurrent()->GetFileRank());
	AssertInt(FIRT_FileSystem, cIter.GetCurrent()->GetType());

	AssertStringCase("Models/Super/Ken.txt", cFiles.Iterate(&cIter)->GetFullName(), FALSE); 
	AssertInt(FILE_SYSTEM_RANK, cIter.GetCurrent()->GetFileRank());
	AssertInt(FIRT_FileSystem, cIter.GetCurrent()->GetType());

	AssertStringCase("Models/Cars.txt", cFiles.Iterate(&cIter)->GetFullName(), FALSE); 
	AssertInt(FILE_SYSTEM_RANK, cIter.GetCurrent()->GetFileRank());
	AssertInt(FIRT_FileSystem, cIter.GetCurrent()->GetType());

	AssertStringCase("Sounds/Santa/Seattle.txt", cFiles.Iterate(&cIter)->GetFullName(), FALSE); 
	AssertInt(FILE_SYSTEM_RANK, cIter.GetCurrent()->GetFileRank());
	AssertInt(FIRT_FileSystem, cIter.GetCurrent()->GetType());

	AssertStringCase("Sounds/Ambient.txt", cFiles.Iterate(&cIter)->GetFullName(), FALSE); 
	AssertInt(FILE_SYSTEM_RANK, cIter.GetCurrent()->GetFileRank());
	AssertInt(FIRT_FileSystem, cIter.GetCurrent()->GetType());

	AssertStringCase("Videos/Intro.txt", cFiles.Iterate(&cIter)->GetFullName(), FALSE); 
	AssertInt(FILE_SYSTEM_RANK, cIter.GetCurrent()->GetFileRank());
	AssertInt(FIRT_FileSystem, cIter.GetCurrent()->GetType());

	AssertStringCase("Videos/Outro.txt", cFiles.Iterate(&cIter)->GetFullName(), FALSE); 
	AssertInt(FILE_SYSTEM_RANK, cIter.GetCurrent()->GetFileRank());
	AssertInt(FIRT_FileSystem, cIter.GetCurrent()->GetType());

	AssertNull(cFiles.Iterate(&cIter));
	AssertNull(cIter.GetCurrent());
	cFiles.StopIteration(&cIter);

	cFiles.Kill();
}