123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- #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<string> 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<string>& 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;
- }
|