Skip to content
Snippets Groups Projects
Commit 97f880e6 authored by Dmitry Kalinkin's avatar Dmitry Kalinkin Committed by Brad King
Browse files

Directory: add extra tests involving errorMessage

parent f33ef4e3
No related branches found
No related tags found
No related merge requests found
......@@ -57,7 +57,11 @@ int _doLongPathTest()
Directory testdir;
// Set res to failure if the directory doesn't load
res += !testdir.Load(testdirpath);
std::string errorMessage = "";
res += !testdir.Load(testdirpath, &errorMessage);
if (errorMessage != "") {
std::cerr << "Failed to list directory: " << errorMessage << std::endl;
}
// Increment res failure if the directory appears empty
res += testdir.GetNumberOfFiles() == 0;
// Increment res failures if the path has changed from
......@@ -73,6 +77,34 @@ int _doLongPathTest()
return res;
}
int _nonExistentDirectoryTest()
{
using namespace kwsys;
int res = 0;
std::string testdirpath(TEST_SYSTEMTOOLS_BINARY_DIR
"/directory_testing/doesnt_exist/");
std::string errorMessage;
Directory testdir;
errorMessage = "foo";
// Increment res failure if directory lists
res += testdir.Load(testdirpath, &errorMessage);
#if !defined(_WIN32) || defined(__CYGWIN__)
// Increment res failure if errorMessage is unmodified
res += (errorMessage == "foo");
#endif
errorMessage = "foo";
// Increment res failure if directory has files
res += (testdir.GetNumberOfFilesInDirectory(testdirpath, &errorMessage) > 0);
#if !defined(_WIN32) || defined(__CYGWIN__)
// Increment res failure if errorMessage is unmodified
res += (errorMessage == "foo");
#endif
return res;
}
int _copyDirectoryTest()
{
using namespace kwsys;
......@@ -106,5 +138,6 @@ int _copyDirectoryTest()
int testDirectory(int, char* [])
{
return _doLongPathTest() + _copyDirectoryTest();
return _doLongPathTest() + _nonExistentDirectoryTest() +
_copyDirectoryTest();
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment