mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-23 12:44:02 +00:00
TESTBED: Add createDirectory() test in FStests
This commit is contained in:
parent
7553940792
commit
43b4528552
@ -172,6 +172,35 @@ TestExitStatus FStests::testWriteFile() {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This test creates a directory testbed.dir, and confirms if the directory is created successfully
|
||||
*/
|
||||
TestExitStatus FStests::testCreateDir() {
|
||||
const Common::String &path = ConfMan.get("path");
|
||||
Common::FSNode gameRoot(path);
|
||||
if (!gameRoot.exists()) {
|
||||
Testsuite::logPrintf("Couldn't open the game data directory %s", path.c_str());
|
||||
return kTestFailed;
|
||||
}
|
||||
|
||||
Common::FSNode dirToCreate = gameRoot.getChild("testbed.dir");
|
||||
|
||||
// TODO: Delete the directory after creating it
|
||||
if (dirToCreate.exists()) {
|
||||
Testsuite::logDetailedPrintf("Directory already exists in game data dir\n");
|
||||
return kTestSkipped;
|
||||
}
|
||||
|
||||
if (!dirToCreate.createDirectory()) {
|
||||
Testsuite::logDetailedPrintf("Can't create directory in game data dir\n");
|
||||
return kTestFailed;
|
||||
}
|
||||
|
||||
Testsuite::logDetailedPrintf("Directory created successfully\n");
|
||||
return kTestPassed;
|
||||
}
|
||||
|
||||
|
||||
|
||||
FSTestSuite::FSTestSuite() {
|
||||
// FS tests depend on Game Data files.
|
||||
@ -187,6 +216,7 @@ FSTestSuite::FSTestSuite() {
|
||||
}
|
||||
addTest("ReadingFile", &FStests::testReadFile, false);
|
||||
addTest("WritingFile", &FStests::testWriteFile, false);
|
||||
addTest("CreateDir", &FStests::testCreateDir, false);
|
||||
}
|
||||
|
||||
void FSTestSuite::enable(bool flag) {
|
||||
|
@ -41,6 +41,7 @@ bool readDataFromFile(Common::FSDirectory *directory, const char *file);
|
||||
// will contain function declarations for FS tests
|
||||
TestExitStatus testReadFile();
|
||||
TestExitStatus testWriteFile();
|
||||
TestExitStatus testCreateDir();
|
||||
TestExitStatus testOpeningSaveFile();
|
||||
// add more here
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user