Commit 6e1bab99 authored by hybrid's avatar hybrid

Add some more archive testing.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2821 dfc29bdd-3216-0410-991c-e03cc46cb475
parent c35ca282
...@@ -4,20 +4,11 @@ using namespace irr; ...@@ -4,20 +4,11 @@ using namespace irr;
using namespace core; using namespace core;
using namespace io; using namespace io;
bool pakReader(void) bool testArchive(IFileSystem* fs, const io::path& archiveName)
{ {
IrrlichtDevice * device = irr::createDevice(video::EDT_NULL, dimension2d<u32>(1, 1)); if ( !fs->addFileArchive(archiveName, /*bool ignoreCase=*/true, /*bool ignorePaths=*/false) )
assert(device);
if(!device)
return false;
io::IFileSystem * fs = device->getFileSystem ();
if ( !fs )
return false;
if ( !fs->addFileArchive(io::path("media/sample_pakfile.pak"), /*bool ignoreCase=*/true, /*bool ignorePaths=*/false) )
return false; return false;
// log what we got // log what we got
io::IFileArchive* archive = fs->getFileArchive(fs->getFileArchiveCount()-1); io::IFileArchive* archive = fs->getFileArchive(fs->getFileArchiveCount()-1);
const io::IFileList* fileList = archive->getFileList(); const io::IFileList* fileList = archive->getFileList();
...@@ -27,26 +18,60 @@ bool pakReader(void) ...@@ -27,26 +18,60 @@ bool pakReader(void)
logTestString("Full path: %s\n", fileList->getFullFileName(f).c_str()); logTestString("Full path: %s\n", fileList->getFullFileName(f).c_str());
} }
bool result = true; io::path filename("mypath/mypath/myfile.txt");
io::path filename("test/test.txt"); if (!fs->existFile(filename))
result &= fs->existFile(filename); {
if (!result ) logTestString("existFile with deep path failed");
return false;
}
filename="test/test.txt";
if (!fs->existFile(filename))
{ {
logTestString("existFile failed"); logTestString("existFile failed");
return false;
} }
IReadFile* readFile = fs->createAndOpenFile(filename); IReadFile* readFile = fs->createAndOpenFile(filename);
if ( !readFile ) if ( !readFile )
{ {
result = false;
logTestString("createAndOpenFilefailed"); logTestString("createAndOpenFilefailed");
return false;
} }
char tmp[123] = {'\0'}; char tmp[13] = {'\0'};
readFile->read(tmp, sizeof(tmp)); readFile->read(tmp, 12);
if (strncmp(tmp, "Hello world!", sizeof(tmp))) if (strncmp(tmp, "Hello world!", 12))
{ {
result = false; logTestString("Read bad data from archive: %s", tmp);
logTestString("Read bad data from pak file.\n"); return false;
} }
return result; if (!fs->removeFileArchive(fs->getFileArchiveCount()-1))
{
logTestString("Couldn't remove archive.\n");
return false;
}
return true;
} }
bool archiveReader()
{
IrrlichtDevice * device = irr::createDevice(video::EDT_NULL, dimension2d<u32>(1, 1));
assert(device);
if(!device)
return false;
io::IFileSystem * fs = device->getFileSystem ();
if ( !fs )
return false;
bool ret = true;
logTestString("Testing zip files.\n");
ret &= testArchive(fs, "media/file_with_path.zip");
logTestString("Testing pak files.\n");
ret &= testArchive(fs, "media/sample_pakfile.pak");
logTestString("Testing npk files.\n");
ret &= testArchive(fs, "media/file_with_path.npk");
return ret;
}
...@@ -57,8 +57,7 @@ int main(int argumentCount, char * arguments[]) ...@@ -57,8 +57,7 @@ int main(int argumentCount, char * arguments[])
TEST(disambiguateTextures); // Normally you should run this first, since it validates the working directory. TEST(disambiguateTextures); // Normally you should run this first, since it validates the working directory.
TEST(filesystem); TEST(filesystem);
TEST(zipReader); TEST(archiveReader);
TEST(pakReader);
TEST(exports); TEST(exports);
TEST(sceneCollisionManager); TEST(sceneCollisionManager);
TEST(testVector3d); TEST(testVector3d);
......
Test suite pass at GMT Wed Nov 4 16:05:32 2009 Test suite pass at GMT Mon Nov 9 16:57:35 2009
#include "testUtils.h"
using namespace irr;
using namespace core;
using namespace io;
bool zipReader(void)
{
IrrlichtDevice * device = irr::createDevice(video::EDT_NULL, dimension2d<u32>(1, 1));
assert(device);
if(!device)
return false;
io::IFileSystem * fs = device->getFileSystem ();
if ( !fs )
return false;
if ( !fs->addFileArchive(io::path("media/file_with_path.zip"), /*bool ignoreCase=*/true, /*bool ignorePaths=*/false) )
return false;
// log what we got
io::IFileArchive* archive = fs->getFileArchive(fs->getFileArchiveCount()-1);
const io::IFileList* fileList = archive->getFileList();
for ( u32 f=0; f < fileList->getFileCount(); ++f)
{
logTestString("File name: %s\n", fileList->getFileName(f).c_str());
logTestString("Full path: %s\n", fileList->getFullFileName(f).c_str());
}
bool result = true;
io::path filename("mypath/myfile.txt");
result &= fs->existFile(filename);
if (!result )
{
logTestString("existFile failed");
}
IReadFile* readFile = fs->createAndOpenFile(filename);
if ( !readFile )
{
result = false;
logTestString("createAndOpenFilefailed");
}
return result;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment