add test.exe to support fast validation.
This commit is contained in:
parent
5acc341171
commit
8070c241b5
3
Makefile
3
Makefile
@ -10,3 +10,6 @@ obj/boosttest.o: src/boosttest.cpp
|
|||||||
|
|
||||||
obj/script_parser.o: src/script_parser.cpp include/script_parser.h
|
obj/script_parser.o: src/script_parser.cpp include/script_parser.h
|
||||||
g++ -o obj/script_parser.o src/script_parser.cpp -c ${INC}
|
g++ -o obj/script_parser.o src/script_parser.cpp -c ${INC}
|
||||||
|
|
||||||
|
test.exe: src/script_parser.cpp
|
||||||
|
g++ -DTEST src/script_parser.cpp -o test.exe ${INC}
|
@ -1,9 +1,14 @@
|
|||||||
|
#ifdef TEST
|
||||||
|
#else
|
||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
#include <fstream>
|
using namespace boost::unit_test;
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
|
#include <sstream>
|
||||||
#include <script_parser.h>
|
#include <script_parser.h>
|
||||||
|
|
||||||
using namespace boost::unit_test;
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
int parseScript(const char* path) {
|
int parseScript(const char* path) {
|
||||||
@ -14,10 +19,22 @@ int parseScript(const char* path) {
|
|||||||
} else {
|
} else {
|
||||||
string line;
|
string line;
|
||||||
while(getline(script, line, '\n')) {
|
while(getline(script, line, '\n')) {
|
||||||
cout << line <<endl;
|
// cout << line <<endl;
|
||||||
|
string word;
|
||||||
|
istringstream iss(line);
|
||||||
|
while(getline(iss, word, ' ')) {
|
||||||
|
cout << word << "+";
|
||||||
|
}
|
||||||
|
cout << endl;
|
||||||
}
|
}
|
||||||
script.close();
|
script.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef TEST
|
||||||
|
int main(int argc, char** argv) {
|
||||||
|
parseScript(argv[1]);
|
||||||
|
}
|
||||||
|
#endif
|
Loading…
Reference in New Issue
Block a user