Loading src/test/cppack-tests.cpp +21 −0 Original line number Diff line number Diff line #include <cassert> #include <regex> #include "Statsgen.h" Loading @@ -6,6 +7,18 @@ using namespace std; uint64_t count(const std::string& filename, const std::string& regex){ std::ifstream file(filename); uint64_t matches = 0; std::string line; while(getline(file, line)){ if(regex_match(line, std::regex(regex))){ ++matches; } } return matches; } int main(){ Statsgen s0(TESTFILE); s0.generate_stats(); Loading @@ -13,5 +26,13 @@ int main(){ s4.setNbThread(4); s4.generate_stats(); assert(s0 == s4); Statistics r = s4.getResults(); for(int i=1; i <= 10; ++i){ assert(r.length[i] == count(TESTFILE, "^.{" + to_string(i) + "}$")); } assert(r.charactersets["loweralpha"] == count(TESTFILE, "^[a-z]+$")); assert(r.charactersets["upperalpha"] == count(TESTFILE, "^[A-Z]+$")); assert(r.charactersets["numeric"] == count(TESTFILE, "^[0-9]+$")); return 0; } No newline at end of file Loading
src/test/cppack-tests.cpp +21 −0 Original line number Diff line number Diff line #include <cassert> #include <regex> #include "Statsgen.h" Loading @@ -6,6 +7,18 @@ using namespace std; uint64_t count(const std::string& filename, const std::string& regex){ std::ifstream file(filename); uint64_t matches = 0; std::string line; while(getline(file, line)){ if(regex_match(line, std::regex(regex))){ ++matches; } } return matches; } int main(){ Statsgen s0(TESTFILE); s0.generate_stats(); Loading @@ -13,5 +26,13 @@ int main(){ s4.setNbThread(4); s4.generate_stats(); assert(s0 == s4); Statistics r = s4.getResults(); for(int i=1; i <= 10; ++i){ assert(r.length[i] == count(TESTFILE, "^.{" + to_string(i) + "}$")); } assert(r.charactersets["loweralpha"] == count(TESTFILE, "^[a-z]+$")); assert(r.charactersets["upperalpha"] == count(TESTFILE, "^[A-Z]+$")); assert(r.charactersets["numeric"] == count(TESTFILE, "^[0-9]+$")); return 0; } No newline at end of file