Добавил:
Studfiles2
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:Интерпретатор / _sources / MyLanguageTestFramework / test
.cpp#include <fstream>
#include <string>
#include <cctype>
#include <iostream>
#include <algorithm>
#include <cstdlib>
using namespace std;
inline bool notSpace( char ch )
{
return !isspace(ch);
}
int main(int argc, char **argv) {
int all = 0, fail = 0, ok = 0;
ifstream in("_input.tests");
if (!in) {
cerr << "No '_input.tests' file!" << endl;
exit(1);
}
ofstream out("_output.tests");
if (!out) {
cerr << "Can't create '_output.tests' file!" << endl;
exit(1);
}
string line;
while ( getline(in, line) ) {
string::iterator iter = find_if(line.begin(), line.end(), notSpace);
if ( iter == line.end() )
continue;
if (*iter == '#')
continue;
if (*iter == '['){
out << line << endl;
continue;
}
bool negate = false;
if (*iter == '*') {
negate = true;
line = string(line, 1);
}
++all;
out << line << " ....";
cerr << line << endl;
string start("..\\Interpreter.exe -debug " + line);
int res = system(start.c_str());
if (negate)
if (res)
res = 0;
else
res = 1;
if (res){
++fail;
out << "FAILED" << endl;
} else {
++ok;
out << "OK" << endl;
}
}
out << endl << "all: " << all << ", ok: " << ok << ", failed: " << fail <<endl;
}