refile test build.

This commit is contained in:
wangjiacai 2022-01-14 16:48:43 +08:00
parent 8070c241b5
commit 747574948a
2 changed files with 14 additions and 20 deletions

View File

@ -12,4 +12,4 @@ 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 test.exe: src/script_parser.cpp
g++ -DTEST src/script_parser.cpp -o test.exe ${INC} g++ -DTEST src/script_parser.cpp -o test.exe ${INC} ${LIB}

View File

@ -1,34 +1,28 @@
#ifdef TEST
#else
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
using namespace boost::unit_test;
#endif
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
#include <sstream> #include <sstream>
#include <script_parser.h> #include <script_parser.h>
using namespace std; using namespace std;
using namespace boost::unit_test;
int parseScript(const char* path) { int parseScript(const char* path) {
ifstream script(path, ios::in); ifstream script(path, ios::in);
if (!script.is_open()) { BOOST_TEST_REQUIRE(script.is_open(), "open script file failed!");
perror(path);
return ENOENT; string line;
} else { while(getline(script, line, '\n')) {
string line; // cout << line <<endl;
while(getline(script, line, '\n')) { string word;
// cout << line <<endl; istringstream iss(line);
string word; while(getline(iss, word, ' ')) {
istringstream iss(line); cout << word << "+";
while(getline(iss, word, ' ')) {
cout << word << "+";
}
cout << endl;
} }
script.close(); cout << endl;
} }
script.close();
BOOST_TEST(true);
return 0; return 0;
} }