Browse Source

Added tests for FilePath::isAbsolute().


git-svn-id: https://svn.microneil.com/svn/CodeDweller-Tests/trunk@48 b3372362-9eaa-4a85-aa2b-6faa1ab7c995
master
adeniz 9 years ago
parent
commit
d313610ca6
1 changed files with 105 additions and 0 deletions
  1. 105
    0
      TestFilesystem/testFilesystem.cpp

+ 105
- 0
TestFilesystem/testFilesystem.cpp View File

@@ -61,6 +61,86 @@ bool result;
// Tests ///////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
bool testFilePathIsAbsolute() {
char const dirSep = CodeDweller::FilePath::DirectorySeparator;
std::string testPath;
// Test absolute paths.
testPath = dirSep;
testPath += "filename";
if (!CodeDweller::FilePath::isAbsolute(testPath)) {
RETURN_FALSE("isAbsolute() failure");
}
testPath += dirSep;
testPath += "pathcomponent";
if (!CodeDweller::FilePath::isAbsolute(testPath)) {
RETURN_FALSE("isAbsolute() failure");
}
testPath += dirSep;
if (!CodeDweller::FilePath::isAbsolute(testPath)) {
RETURN_FALSE("isAbsolute() failure");
}
#ifdef _WIN32
if (!CodeDweller::FilePath::isAbsolute("x:sll")) {
RETURN_FALSE("isAbsolute() failure");
}
if (!CodeDweller::FilePath::isAbsolute("x:\\sll")) {
RETURN_FALSE("isAbsolute() failure");
}
if (!CodeDweller::FilePath::isAbsolute("x:\\sll\\")) {
RETURN_FALSE("isAbsolute() failure");
}
if (!CodeDweller::FilePath::isAbsolute("x:\\sll\lll")) {
RETURN_FALSE("isAbsolute() failure");
}
if (!CodeDweller::FilePath::isAbsolute("\\sll")) {
RETURN_FALSE("isAbsolute() failure");
}
if (!CodeDweller::FilePath::isAbsolute("\\sll\\")) {
RETURN_FALSE("isAbsolute() failure");
}
if (!CodeDweller::FilePath::isAbsolute("\\sll\lll")) {
RETURN_FALSE("isAbsolute() failure");
}
#endif
// Test relative paths.
if (CodeDweller::FilePath::isAbsolute("")) {
RETURN_FALSE("isAbsolute() failure");
}
testPath = "Hello";
if (CodeDweller::FilePath::isAbsolute(testPath)) {
RETURN_FALSE("isAbsolute() failure");
}
testPath = "Hello";
testPath += dirSep;
if (CodeDweller::FilePath::isAbsolute(testPath)) {
RETURN_FALSE("isAbsolute() failure");
}
testPath = "Hello";
testPath += dirSep;
testPath += "file";
if (CodeDweller::FilePath::isAbsolute(testPath)) {
RETURN_FALSE("isAbsolute() failure");
}
return true;
}
bool testFilePathJoin() {
char const dirSep = CodeDweller::FilePath::DirectorySeparator;
@@ -116,6 +196,30 @@ bool testFilePathJoin() {
RETURN_FALSE("join() failure");
}
try {
(void) CodeDweller::FilePath::join({"rel", "/abs"});
NO_EXCEPTION_TERM("join()");
return false;
} catch (std::exception &e) {
}
try {
(void) CodeDweller::FilePath::join({"rel", "/abs", "otherrel"});
NO_EXCEPTION_TERM("join()");
return false;
} catch (std::exception &e) {
}
return true;
}
long createTestFile(std::string fileName) {
@@ -407,6 +511,7 @@ int main()
{
std::cout << "CodeDweller::Filesystem unit tests" << std::endl << std::endl;
RUN_TEST(testFilePathIsAbsolute);
RUN_TEST(testFilePathJoin);
RUN_TEST(testFileReferenceFile);
RUN_TEST(testFileReferenceNoFile);

Loading…
Cancel
Save