#include #include #include "name.h" using namespace std; bool TestName(string csvIn, string csvOut, string formatted); int main() { ifstream testFile; string lineIn, lineOut, fixed; testFile.open("TestFile.txt"); if (!testFile) { cout << "Failed to open TestFile.txt" << endl; } else { getline(testFile,lineIn); while (testFile) { getline(testFile,lineOut); getline(testFile,fixed); TestName(lineIn, lineOut, fixed); getline(testFile,lineIn); } } return 0; } void PrintError(string msg, string input, string shouldB, string is) { cout << "Error, " << msg << endl; cout << "\tInput \"" << input << "\"" << endl; cout << "\tShould be \"" << shouldB << "\"" << endl; cout << "\tBut is \"" << is << "\"" << endl; return; } bool TestName(string csvIn, string csvOut, string formatted){ NameT a; string out, fixed; bool rv = true; a = CSVToNameT(csvIn); out = NameTToCSV(a); fixed= FormatNameT(a); if (out != csvOut) { PrintError("converting back to CSV", csvIn, csvOut, out); rv = false; } else if (fixed != formatted) { PrintError("converting back to CSV", csvIn, formatted, fixed); rv = false; } return rv; }