소스 검색

Tested DirectoryReference on Windows, implemented FilePath::join().


git-svn-id: https://svn.microneil.com/svn/CodeDweller-Tests/trunk@34 b3372362-9eaa-4a85-aa2b-6faa1ab7c995
master
adeniz 10 년 전
부모
커밋
96eeafbfa4
1개의 변경된 파일65개의 추가작업 그리고 5개의 파일을 삭제
  1. 65
    5
      TestFilesystem/testFilesystem.cpp

+ 65
- 5
TestFilesystem/testFilesystem.cpp 파일 보기

@@ -61,6 +61,63 @@ bool result;
// Tests ///////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
bool testFilePathJoin() {
char const dirSep = CodeDweller::FilePath::DirectorySeparator;
std::vector<std::string> comp0 = {"comp0", "comp1", "comp2"};
std::string expectedComp;
// Test normal joining.
for (auto &comp : comp0) {
expectedComp += comp + dirSep;
}
expectedComp.pop_back();
if (expectedComp !=
CodeDweller::FilePath::join({comp0[0], comp0[1], comp0[2]})) {
RETURN_FALSE("join() failure");
}
// Test null component.
if (expectedComp !=
CodeDweller::FilePath::join({comp0[0], comp0[1], "", comp0[2]})) {
RETURN_FALSE("join() failure");
}
if (expectedComp !=
CodeDweller::FilePath::join({"", comp0[0], comp0[1], "", comp0[2]})) {
RETURN_FALSE("join() failure");
}
if (expectedComp !=
CodeDweller::FilePath::join({"", comp0[0], comp0[1], "", comp0[2], ""})) {
RETURN_FALSE("join() failure");
}
// Test single input.
expectedComp = "test";
if (expectedComp != CodeDweller::FilePath::join({expectedComp})) {
RETURN_FALSE("join() failure");
}
if (expectedComp != CodeDweller::FilePath::join({"", expectedComp})) {
RETURN_FALSE("join() failure");
}
if (expectedComp != CodeDweller::FilePath::join({"", expectedComp, ""})) {
RETURN_FALSE("join() failure");
}
if (expectedComp != CodeDweller::FilePath::join({"", expectedComp, "", ""})) {
RETURN_FALSE("join() failure");
}
if (expectedComp != CodeDweller::FilePath::join({"", "", expectedComp, ""})) {
RETURN_FALSE("join() failure");
}
}
long createTestFile(std::string fileName) {
std::ofstream out(fileName.c_str());
std::string contents = "Content";
@@ -239,13 +296,14 @@ bool filter(std::string name) {
bool testDirectoryReferenceFiles() {
char const dirSep = CodeDweller::FilePath::DirectorySeparator;
std::unordered_set<std::string> fileNames;
std::string filteredFileName = testDirName + "/f1.txt";
std::string filteredFileName = testDirName + dirSep + "f1.txt";
fileNames.emplace(testDirName + "/" + testFileName);
fileNames.emplace(testDirName + dirSep + testFileName);
fileNames.emplace(filteredFileName);
fileNames.emplace(testDirName + "/f2.txt");
fileNames.emplace(testDirName + "/f3.txt");
fileNames.emplace(testDirName + dirSep + "f2.txt");
fileNames.emplace(testDirName + dirSep + "f3.txt");
try {
@@ -315,10 +373,11 @@ bool testDirectoryReferenceFiles() {
return false;
}
#if 0
for (auto &name : fileNames) {
std::remove(name.c_str());
}
#endif
return true;
}
@@ -348,6 +407,7 @@ int main()
{
std::cout << "CodeDweller::Filesystem unit tests" << std::endl << std::endl;
RUN_TEST(testFilePathJoin);
RUN_TEST(testFileReferenceFile);
RUN_TEST(testFileReferenceNoFile);
RUN_TEST(testFileReferenceDir);

Loading…
취소
저장