Loading main.cpp +25 −5 Original line number Diff line number Diff line #include <iostream> #include <vector> // FILE CHECKS #if __has_include("lab5.cpp") Loading Loading @@ -30,8 +31,8 @@ void assertFalse(bool val, std::string failureReport) { void e107(); void p101(); void p102(); void e1112(); void e1116(); void e1112(); int maximum(std::vector<int> values); void e1116(); std::vector<std::string> generate_substrings(std::string s); #elifdef LAB4 void p88(); Loading @@ -53,7 +54,26 @@ void e79(); //char* replace_all(const char s[], const char t[], const char u[]); // TESTS #ifdef LAB5 void teste1112() { std::vector<int> t1{1,2,3,4,5}; std::vector<int> t2{3,1,4,1,5,9,2,6,5,3,5,8,9,7,9,3,2,3}; assertTrue(maximum(t1)==5,"Failed to find the maximum of {1,2,3,4,5}"); assertTrue(maximum(t2)==9,"Failed to find the maximum of {3,1,4,1,5,9,2,6,5,3,5,8,9,7,9,3,2,3"); }; void teste1116() { auto rum = generate_substrings("rum"); // std::vector<std::string> tmp = generate_substrings("rum"); // for (std::string str: tmp) { // std::cout << "'" << str << "'" << std::endl; // } assertTrue(find(rum.begin(),rum.end(),std::string("m"))!=rum.end(),"Could not find 'm' in substrings of 'rum'."); assertTrue(find(rum.begin(),rum.end(),std::string("rm"))!=rum.end(),"Could not find 'rm' in substrings of 'rum'."); assertTrue(find(rum.begin(),rum.end(),std::string("rm"))!=rum.end(),"Could not find 'rum' in substrings of 'rum'."); assertTrue(find(rum.begin(),rum.end(),std::string(""))!=rum.end(),"Could not find '' in substrings of 'rum'."); assertTrue(rum.size()==8,"'rum' has 8 substrings, but "+std::to_string(rum.size())+" found."); } #elifdef LAB4 #elifdef LAB3 Loading Loading @@ -90,8 +110,8 @@ int main() { e107(); p101(); p102(); e1112(); e1116(); e1112(); teste1112(); e1116(); teste1116(); #elifdef LAB4 p88(); e98(); Loading Loading
main.cpp +25 −5 Original line number Diff line number Diff line #include <iostream> #include <vector> // FILE CHECKS #if __has_include("lab5.cpp") Loading Loading @@ -30,8 +31,8 @@ void assertFalse(bool val, std::string failureReport) { void e107(); void p101(); void p102(); void e1112(); void e1116(); void e1112(); int maximum(std::vector<int> values); void e1116(); std::vector<std::string> generate_substrings(std::string s); #elifdef LAB4 void p88(); Loading @@ -53,7 +54,26 @@ void e79(); //char* replace_all(const char s[], const char t[], const char u[]); // TESTS #ifdef LAB5 void teste1112() { std::vector<int> t1{1,2,3,4,5}; std::vector<int> t2{3,1,4,1,5,9,2,6,5,3,5,8,9,7,9,3,2,3}; assertTrue(maximum(t1)==5,"Failed to find the maximum of {1,2,3,4,5}"); assertTrue(maximum(t2)==9,"Failed to find the maximum of {3,1,4,1,5,9,2,6,5,3,5,8,9,7,9,3,2,3"); }; void teste1116() { auto rum = generate_substrings("rum"); // std::vector<std::string> tmp = generate_substrings("rum"); // for (std::string str: tmp) { // std::cout << "'" << str << "'" << std::endl; // } assertTrue(find(rum.begin(),rum.end(),std::string("m"))!=rum.end(),"Could not find 'm' in substrings of 'rum'."); assertTrue(find(rum.begin(),rum.end(),std::string("rm"))!=rum.end(),"Could not find 'rm' in substrings of 'rum'."); assertTrue(find(rum.begin(),rum.end(),std::string("rm"))!=rum.end(),"Could not find 'rum' in substrings of 'rum'."); assertTrue(find(rum.begin(),rum.end(),std::string(""))!=rum.end(),"Could not find '' in substrings of 'rum'."); assertTrue(rum.size()==8,"'rum' has 8 substrings, but "+std::to_string(rum.size())+" found."); } #elifdef LAB4 #elifdef LAB3 Loading Loading @@ -90,8 +110,8 @@ int main() { e107(); p101(); p102(); e1112(); e1116(); e1112(); teste1112(); e1116(); teste1116(); #elifdef LAB4 p88(); e98(); Loading