test: fixed tests
This commit is contained in:
@@ -18,8 +18,7 @@ public:
|
||||
{
|
||||
std::vector<FilePath> sourcePaths;
|
||||
sourcePaths.push_back("./data/FileManagerTestSuite/src/");
|
||||
std::vector<FilePath> includePaths;
|
||||
includePaths.push_back("./data/FileManagerTestSuite/include/");
|
||||
sourcePaths.push_back("./data/FileManagerTestSuite/include/");
|
||||
std::vector<std::string> sourceExtensions;
|
||||
sourceExtensions.push_back(".cpp");
|
||||
sourceExtensions.push_back(".c");
|
||||
@@ -28,88 +27,9 @@ public:
|
||||
includeExtensions.push_back(".h");
|
||||
|
||||
FileManager fm;
|
||||
fm.setPaths(sourcePaths, includePaths, sourceExtensions, includeExtensions);
|
||||
fm.setPaths(sourcePaths, sourceExtensions, includeExtensions);
|
||||
fm.fetchFilePaths(std::vector<FileInfo>());
|
||||
|
||||
TS_ASSERT_EQUALS(fm.getAddedFilePaths().size(), 4);
|
||||
}
|
||||
|
||||
void test_file_manager_has_no_added_file_paths_after_second_fetch()
|
||||
{
|
||||
std::vector<FilePath> sourcePaths;
|
||||
sourcePaths.push_back("./data/FileManagerTestSuite/src/");
|
||||
std::vector<FilePath> includePaths;
|
||||
includePaths.push_back("./data/FileManagerTestSuite/include/");
|
||||
std::vector<std::string> sourceExtensions;
|
||||
sourceExtensions.push_back(".cpp");
|
||||
sourceExtensions.push_back(".c");
|
||||
std::vector<std::string> includeExtensions;
|
||||
includeExtensions.push_back(".hpp");
|
||||
includeExtensions.push_back(".h");
|
||||
|
||||
FileManager fm;
|
||||
fm.setPaths(sourcePaths, includePaths, sourceExtensions, includeExtensions);
|
||||
fm.fetchFilePaths(std::vector<FileInfo>());
|
||||
fm.fetchFilePaths(std::vector<FileInfo>());
|
||||
|
||||
TS_ASSERT_EQUALS(fm.getAddedFilePaths().size(), 0);
|
||||
}
|
||||
|
||||
void test_file_manager_has_updated_file_paths_after_second_fetch()
|
||||
{
|
||||
std::vector<FilePath> sourcePaths;
|
||||
sourcePaths.push_back("./data/FileManagerTestSuite/src/");
|
||||
std::vector<FilePath> includePaths;
|
||||
includePaths.push_back("./data/FileManagerTestSuite/include/");
|
||||
std::vector<std::string> sourceExtensions;
|
||||
sourceExtensions.push_back(".cpp");
|
||||
sourceExtensions.push_back(".c");
|
||||
std::vector<std::string> includeExtensions;
|
||||
includeExtensions.push_back(".hpp");
|
||||
includeExtensions.push_back(".h");
|
||||
|
||||
FileManager fm;
|
||||
fm.setPaths(sourcePaths, includePaths, sourceExtensions, includeExtensions);
|
||||
fm.fetchFilePaths(std::vector<FileInfo>());
|
||||
|
||||
std::fstream fileStream;
|
||||
fileStream.open("./data/FileManagerTestSuite/include/c.h");
|
||||
fileStream << "update";
|
||||
fileStream.close();
|
||||
|
||||
fm.fetchFilePaths(std::vector<FileInfo>());
|
||||
|
||||
TS_ASSERT_EQUALS(fm.getAddedFilePaths().size(), 0);
|
||||
TS_ASSERT_EQUALS(fm.getUpdatedFilePaths().size(), 1);
|
||||
TS_ASSERT_EQUALS(fm.getRemovedFilePaths().size(), 0);
|
||||
}
|
||||
|
||||
void test_file_manager_has_added_and_removed_file_paths_after_setting_different_paths()
|
||||
{
|
||||
std::vector<FilePath> sourcePaths(1, "./data/FileManagerTestSuite/src/a.cpp");
|
||||
std::vector<FilePath> includePaths(1, "./data/FileManagerTestSuite/include/c.h");
|
||||
std::vector<std::string> sourceExtensions;
|
||||
sourceExtensions.push_back(".cpp");
|
||||
sourceExtensions.push_back(".c");
|
||||
std::vector<std::string> includeExtensions;
|
||||
includeExtensions.push_back(".hpp");
|
||||
includeExtensions.push_back(".h");
|
||||
|
||||
FileManager fm;
|
||||
fm.setPaths(sourcePaths, includePaths, sourceExtensions, includeExtensions);
|
||||
fm.fetchFilePaths(std::vector<FileInfo>());
|
||||
|
||||
TS_ASSERT_EQUALS(fm.getAddedFilePaths().size(), 2);
|
||||
TS_ASSERT_EQUALS(fm.getUpdatedFilePaths().size(), 0);
|
||||
TS_ASSERT_EQUALS(fm.getRemovedFilePaths().size(), 0);
|
||||
|
||||
sourcePaths[0] = "./data/FileManagerTestSuite/src/d.c";
|
||||
|
||||
fm.setPaths(sourcePaths, includePaths, sourceExtensions, includeExtensions);
|
||||
fm.fetchFilePaths(std::vector<FileInfo>());
|
||||
|
||||
TS_ASSERT_EQUALS(fm.getAddedFilePaths().size(), 1);
|
||||
TS_ASSERT_EQUALS(fm.getUpdatedFilePaths().size(), 0);
|
||||
TS_ASSERT_EQUALS(fm.getRemovedFilePaths().size(), 1);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -174,14 +174,14 @@ public:
|
||||
std::vector<SearchMatch> matches = index.runFuzzySearchAndGetMatches("t");
|
||||
|
||||
TS_ASSERT_EQUALS(2, matches.size());
|
||||
TS_ASSERT_EQUALS("MATH", matches[0].fullName);
|
||||
TS_ASSERT_EQUALS("util", matches[1].fullName);
|
||||
TS_ASSERT_EQUALS("util", matches[0].fullName);
|
||||
TS_ASSERT_EQUALS("MATH", matches[1].fullName);
|
||||
|
||||
matches = index.runFuzzySearchAndGetMatches("T");
|
||||
|
||||
TS_ASSERT_EQUALS(2, matches.size());
|
||||
TS_ASSERT_EQUALS("MATH", matches[0].fullName);
|
||||
TS_ASSERT_EQUALS("util", matches[1].fullName);
|
||||
TS_ASSERT_EQUALS("util", matches[0].fullName);
|
||||
TS_ASSERT_EQUALS("MATH", matches[1].fullName);
|
||||
}
|
||||
|
||||
void test_fuzzy_matching_wheighs_by_distance_and_alphabet()
|
||||
|
||||
Reference in New Issue
Block a user