#include "TestLogger.h" TestLogger::TestLogger() { } void TestLogger::print(const string* message, exception* ex, const string* function, const string* scriptname, const Script* sc, int line) { if(ex == nullptr) { if(message != nullptr) { output.push_back(*message); } } else { output.push_back(ex->what()); } } void TestLogger::reset() { output.clear(); } bool TestLogger::check(const string& name, fstream& check) { vector file; while(!check.eof()) { char buffer[256]; check.getline(buffer, 256); if(buffer[0] != '\0') { file.push_back(buffer); } } if(file.size() != output.size()) { printNoMatch(name, file); return false; } for(unsigned int i = 0; i < file.size(); i++) { if(file[i] != output[i]) { printNoMatch(name, file); return false; } } return true; } void TestLogger::printNoMatch(const string& name, vector& file) { cout << "error checking " << name << endl; cout << "Expected ---------------------------------------------" << endl; for(unsigned int i = 0; i < file.size(); i++) { cout << file[i] << endl; } cout << "Actual -----------------------------------------------" << endl; for(unsigned int i = 0; i < output.size(); i++) { cout << output[i] << endl; } cout << "------------------------------------------------------" << endl; }