Created
May 31, 2015 20:11
-
-
Save drewpts/4947d6f2f93f62a72924 to your computer and use it in GitHub Desktop.
find subprojects by path
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
virtual FileSetLoader * findSubprojectByPath(const Path&) const = 0; | |
//////////////////////////////// | |
/*! | |
* \brief This function performs searching existing subproject loader by path to | |
* subproject | |
* \param[in] std::string with path to subproject | |
* \return loader of subproject | |
*/ | |
/*virtual*/ FileSetLoader * findSubprojectByPath(const FileSetLoader::Path & path) const; | |
FileSetLoader * | |
JsonFileSetLoader::findSubprojectByPath(const std::string &path) const | |
{ | |
for (auto it = subprojects.cbegin(); it != subprojects.cend(); ++it) | |
{ | |
if (it->second->getPathToNode() == path) | |
return it->second; | |
} | |
throw FileSetRuntimeError(FileSetRuntimeError::SubprojectsIncongruity, "Subproject not found by path search"); | |
} | |
//////////////////////// | |
class TestFindSubprojectByPath : public TestSkeleton { | |
public: | |
FileSetLoader::Path pathToProjectWithOneNormalSubprojects = R"(project_files/getsubprojectspaths/getpath.libproject)"; | |
FileSetLoader::Path pathToProjectWithPairNormalSubprojects = R"(project_files/getsubprojectspaths/getpaths.libproject)"; | |
FileSetLoader::Path pathToProjectWithoutSubprojects = R"(project_files/getsubprojectspaths/nosubprojects.libproject)"; | |
FileSetLoader::Path pathToOneSubproject = ""; | |
FileSetLoader::Path pathToAnotherSubproject = ""; | |
FileSetLoader::Path pathToNonExistentSubproject = ""; | |
}; | |
TEST_F(TestFindSubprojectByPath, FindInProjectWithTwoSubprojects) { | |
ASSERT_NO_THROW({ | |
loader = LoaderPtr(FileSetFactory::createFileSet(pathToProjectWithPairNormalSubprojects)); | |
loader->open; | |
loader->findSubprojectByPath; | |
}); | |
loader->save(); | |
ifstream i(pathToMainFileWhichWillNotBeLoaded); | |
fileToTest << i; | |
ASSERT_EQ(contentReference_withTwoSuprojects.dump(4), fileToTest.dump(4)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment