aligned tests to latest changes

This commit is contained in:
john30
2018-04-04 15:49:48 +02:00
parent bd5f800426
commit 2a348c2087
4 changed files with 37 additions and 17 deletions
+3 -3
View File
@@ -118,7 +118,7 @@ int main() {
istringstream dummystr("#"); istringstream dummystr("#");
string errorDescription; string errorDescription;
vector<string> row; vector<string> row;
templates->readLineFromStream("inline", false, &dummystr, &lineNo, &row, &errorDescription, NULL, NULL); templates->readLineFromStream(&dummystr, "inline", false, &lineNo, &row, &errorDescription, NULL, NULL);
const DataField* fields = NULL; const DataField* fields = NULL;
for (unsigned int i = 0; i < sizeof(checks) / sizeof(checks[0]); i++) { for (unsigned int i = 0; i < sizeof(checks) / sizeof(checks[0]); i++) {
string check[5] = checks[i]; string check[5] = checks[i];
@@ -156,7 +156,7 @@ int main() {
lineNo = 0; lineNo = 0;
dummystr.clear(); dummystr.clear();
dummystr.str("#"); dummystr.str("#");
result = reader.readLineFromStream("inline", false, &dummystr, &lineNo, &row, &errorDescription, NULL, NULL); result = reader.readLineFromStream(&dummystr, "inline", false, &lineNo, &row, &errorDescription, NULL, NULL);
if (result != RESULT_OK) { if (result != RESULT_OK) {
cout << "\"" << check[0] << "\": reader header error: " << getResultCode(result) << ", " << errorDescription cout << "\"" << check[0] << "\": reader header error: " << getResultCode(result) << ", " << errorDescription
<< endl; << endl;
@@ -164,7 +164,7 @@ int main() {
continue; continue;
} }
lineNo = baseLine + i; lineNo = baseLine + i;
result = reader.readLineFromStream(__FILE__, false, &isstr, &lineNo, &row, &errorDescription, NULL, NULL); result = reader.readLineFromStream(&isstr, __FILE__, false, &lineNo, &row, &errorDescription, NULL, NULL);
fields = reader.m_fields; fields = reader.m_fields;
if (result != RESULT_OK) { if (result != RESULT_OK) {
+4 -4
View File
@@ -512,7 +512,7 @@ int main() {
istringstream dummystr("#"); istringstream dummystr("#");
string errorDescription; string errorDescription;
vector<string> row; vector<string> row;
templates->readLineFromStream(__FILE__, false, &dummystr, &lineNo, &row, &errorDescription, NULL, NULL); templates->readLineFromStream(&dummystr, __FILE__, false, &lineNo, &row, &errorDescription, NULL, NULL);
const DataField* fields = NULL; const DataField* fields = NULL;
for (unsigned int i = 0; i < sizeof(checks) / sizeof(checks[0]); i++) { for (unsigned int i = 0; i < sizeof(checks) / sizeof(checks[0]); i++) {
string check[5] = checks[i]; string check[5] = checks[i];
@@ -567,7 +567,7 @@ int main() {
} }
if (isTemplate) { if (isTemplate) {
lineNo = baseLine + i; lineNo = baseLine + i;
result = templates->readLineFromStream(__FILE__, false, &isstr, &lineNo, &row, &errorDescription, NULL, NULL); result = templates->readLineFromStream(&isstr, __FILE__, false, &lineNo, &row, &errorDescription, NULL, NULL);
if (result != RESULT_OK) { if (result != RESULT_OK) {
cout << "\"" << check[0] << "\": template read error: " << getResultCode(result) << ", " cout << "\"" << check[0] << "\": template read error: " << getResultCode(result) << ", "
<< errorDescription << endl; << errorDescription << endl;
@@ -579,7 +579,7 @@ int main() {
lineNo = 0; lineNo = 0;
dummystr.clear(); dummystr.clear();
dummystr.str("#"); dummystr.str("#");
result = reader.readLineFromStream(__FILE__, false, &dummystr, &lineNo, &row, &errorDescription, NULL, NULL); result = reader.readLineFromStream(&dummystr, __FILE__, false, &lineNo, &row, &errorDescription, NULL, NULL);
if (result != RESULT_OK) { if (result != RESULT_OK) {
cout << "\"" << check[0] << "\": read header error: " << getResultCode(result) << ", " << errorDescription cout << "\"" << check[0] << "\": read header error: " << getResultCode(result) << ", " << errorDescription
<< endl; << endl;
@@ -587,7 +587,7 @@ int main() {
continue; continue;
} }
lineNo = baseLine + i; lineNo = baseLine + i;
result = reader.readLineFromStream("", false, &isstr, &lineNo, &row, &errorDescription, NULL, NULL); result = reader.readLineFromStream(&isstr, "", false, &lineNo, &row, &errorDescription, NULL, NULL);
fields = reader.m_fields; fields = reader.m_fields;
if (failedCreate) { if (failedCreate) {
if (result == RESULT_OK) { if (result == RESULT_OK) {
+9 -5
View File
@@ -196,7 +196,13 @@ int main(int argc, char** argv) {
size_t hash = 0, size = 0; size_t hash = 0, size = 0;
time_t time = 0; time_t time = 0;
string errorDescription; string errorDescription;
result_t result = reader.readFromFile(argv[argpos], false, NULL, &errorDescription, &hash, &size, &time); istream* stream = FileReader::openFile(argv[argpos], &errorDescription, &time);
result_t result;
if (!stream) {
result = RESULT_ERR_NOTFOUND;
} else {
result = reader.readFromStream(stream, argv[argpos], time, false, NULL, &errorDescription, &hash, &size);
}
cout << argv[argpos] << " "; cout << argv[argpos] << " ";
if (result != RESULT_OK) { if (result != RESULT_OK) {
cout << getResultCode(result) << ", " << errorDescription << endl; cout << getResultCode(result) << ", " << errorDescription << endl;
@@ -225,8 +231,7 @@ int main(int argc, char** argv) {
vector<string> row; vector<string> row;
string errorDescription; string errorDescription;
while (ifs.peek() != EOF) { while (ifs.peek() != EOF) {
istringstream str; result_t result = reader.readLineFromStream(&ifs, "", true, &lineNo, &row, &errorDescription, &hash, &size);
result_t result = reader.readLineFromStream("", true, &ifs, &lineNo, &row, &errorDescription, &hash, &size);
if (result != RESULT_OK) { if (result != RESULT_OK) {
cout << " error " << getResultCode(result) << endl; cout << " error " << getResultCode(result) << endl;
error = true; error = true;
@@ -266,8 +271,7 @@ int main(int argc, char** argv) {
subDefaults.resize(1); subDefaults.resize(1);
subDefaults[0]["subcol 2"] = ";default of sub 0 subcol 2"; subDefaults[0]["subcol 2"] = ";default of sub 0 subcol 2";
while (ifs.peek() != EOF) { while (ifs.peek() != EOF) {
istringstream str; result_t result = reader2.readLineFromStream(&ifs, "", true, &lineNo, &row, &errorDescription, &hash, &size);
result_t result = reader2.readLineFromStream("", true, &ifs, &lineNo, &row, &errorDescription, &hash, &size);
if (result != RESULT_OK) { if (result != RESULT_OK) {
cout << " error " << getResultCode(result) << endl; cout << " error " << getResultCode(result) << endl;
error = true; error = true;
+21 -5
View File
@@ -60,8 +60,24 @@ DataFieldTemplates* getTemplates(const string& filename) {
} }
return templates; return templates;
} }
result_t loadDefinitionsFromConfigPath(FileReader* reader, const string& filename, bool verbose,
map<string, string>* defaults, string* errorDescription) {
time_t mtime = 0;
istream* stream = FileReader::openFile(filename, errorDescription, &mtime);
result_t result;
if (stream) {
result = reader->readFromStream(stream, filename, mtime, verbose, defaults, errorDescription);
delete(stream);
} else {
result = RESULT_ERR_NOTFOUND;
}
return result;
} }
} // namespace ebusd
int main() { int main() {
// message: [type],[circuit],name,[comment],[QQ[;QQ]*],[ZZ],[PBSB],[ID],fields... // message: [type],[circuit],name,[comment],[QQ[;QQ]*],[ZZ],[PBSB],[ID],fields...
// field: name,part,type[:len][,[divisor|values][,[unit][,[comment]]]] // field: name,part,type[:len][,[divisor|values][,[unit][,[comment]]]]
@@ -170,12 +186,12 @@ int main() {
istringstream dummystr("#"); istringstream dummystr("#");
string errorDescription; string errorDescription;
vector<string> row; vector<string> row;
templates->readLineFromStream(__FILE__, false, &dummystr, &lineNo, &row, &errorDescription, NULL, NULL); templates->readLineFromStream(&dummystr, __FILE__, false, &lineNo, &row, &errorDescription, NULL, NULL);
lineNo = 0; lineNo = 0;
MessageMap* messages = new MessageMap(""); MessageMap* messages = new MessageMap("");
dummystr.clear(); dummystr.clear();
dummystr.str("#"); dummystr.str("#");
messages->readLineFromStream(__FILE__, false, &dummystr, &lineNo, &row, &errorDescription, NULL, NULL); messages->readLineFromStream(&dummystr, __FILE__, false, &lineNo, &row, &errorDescription, NULL, NULL);
vector< vector<string> > defaultsRows; vector< vector<string> > defaultsRows;
Message* message = NULL; Message* message = NULL;
vector<MasterSymbolString*> mstrs; vector<MasterSymbolString*> mstrs;
@@ -206,7 +222,7 @@ int main() {
lineNo = baseLine + i; lineNo = baseLine + i;
cout << "line " << (lineNo+1) << " "; cout << "line " << (lineNo+1) << " ";
if (isTemplate) { if (isTemplate) {
result = templates->readLineFromStream(__FILE__, false, &isstr, &lineNo, &row, &errorDescription, NULL, NULL); result = templates->readLineFromStream(&isstr, __FILE__, false, &lineNo, &row, &errorDescription, NULL, NULL);
if (result != RESULT_OK) { if (result != RESULT_OK) {
cout << "\"" << check[0] << "\": template read error: " << getResultCode(result) << ", " << errorDescription cout << "\"" << check[0] << "\": template read error: " << getResultCode(result) << ", " << errorDescription
<< endl; << endl;
@@ -220,7 +236,7 @@ int main() {
} }
if (isstr.peek() == '*') { if (isstr.peek() == '*') {
// store defaults or condition // store defaults or condition
result = messages->readLineFromStream(__FILE__, false, &isstr, &lineNo, &row, &errorDescription, NULL, NULL); result = messages->readLineFromStream(&isstr, __FILE__, false, &lineNo, &row, &errorDescription, NULL, NULL);
if (result != RESULT_OK) { if (result != RESULT_OK) {
cout << "\"" << check[0] << "\": default read error: " << getResultCode(result) << ", " << errorDescription << endl; cout << "\"" << check[0] << "\": default read error: " << getResultCode(result) << ", " << errorDescription << endl;
error = true; error = true;
@@ -302,7 +318,7 @@ int main() {
} }
cout << "\"" << check[2] << "\": find OK" << endl; cout << "\"" << check[2] << "\": find OK" << endl;
} else { } else {
result = messages->readLineFromStream(__FILE__, false, &isstr, &lineNo, &row, &errorDescription, NULL, NULL); result = messages->readLineFromStream(&isstr, __FILE__, false, &lineNo, &row, &errorDescription, NULL, NULL);
if (failedCreate) { if (failedCreate) {
if (result == RESULT_OK) { if (result == RESULT_OK) {
cout << "\"" << check[0] << "\": failed create error: unexpectedly succeeded" << endl; cout << "\"" << check[0] << "\": failed create error: unexpectedly succeeded" << endl;