aligned tests with latest FileReader changes

This commit is contained in:
john30
2018-04-08 13:48:52 +02:00
parent 000d68f3c2
commit bee1fc5b8a
4 changed files with 20 additions and 20 deletions
+4 -4
View File
@@ -70,7 +70,7 @@ class TestReader : public MappedFileReader {
return RESULT_OK; // leave it to DataField::create
}
result_t addFromFile(const string& filename, unsigned int lineNo, map<string, string>* row,
vector< map<string, string> >* subRows, string* errorDescription) override {
vector< map<string, string> >* subRows, string* errorDescription, bool replace) override {
if (!row->empty() || subRows->empty()) {
cout << "read line " << static_cast<unsigned>(lineNo) << ": read error: got "
<< static_cast<unsigned>(row->size()) << "/0 main, " << static_cast<unsigned>(subRows->size())
@@ -118,7 +118,7 @@ int main() {
istringstream dummystr("#");
string errorDescription;
vector<string> row;
templates->readLineFromStream(&dummystr, "inline", false, &lineNo, &row, &errorDescription, NULL, NULL);
templates->readLineFromStream(&dummystr, "inline", false, &lineNo, &row, &errorDescription, false, NULL, NULL);
const DataField* fields = NULL;
for (unsigned int i = 0; i < sizeof(checks) / sizeof(checks[0]); i++) {
string check[5] = checks[i];
@@ -156,7 +156,7 @@ int main() {
lineNo = 0;
dummystr.clear();
dummystr.str("#");
result = reader.readLineFromStream(&dummystr, "inline", false, &lineNo, &row, &errorDescription, NULL, NULL);
result = reader.readLineFromStream(&dummystr, "inline", false, &lineNo, &row, &errorDescription, false, NULL, NULL);
if (result != RESULT_OK) {
cout << "\"" << check[0] << "\": reader header error: " << getResultCode(result) << ", " << errorDescription
<< endl;
@@ -164,7 +164,7 @@ int main() {
continue;
}
lineNo = baseLine + i;
result = reader.readLineFromStream(&isstr, __FILE__, false, &lineNo, &row, &errorDescription, NULL, NULL);
result = reader.readLineFromStream(&isstr, __FILE__, false, &lineNo, &row, &errorDescription, false, NULL, NULL);
fields = reader.m_fields;
if (result != RESULT_OK) {
+5 -5
View File
@@ -69,7 +69,7 @@ class TestReader : public MappedFileReader {
return RESULT_OK; // leave it to DataField::create
}
result_t addFromFile(const string& filename, unsigned int lineNo, map<string, string>* row,
vector< map<string, string> >* subRows, string* errorDescription) override {
vector< map<string, string> >* subRows, string* errorDescription, bool replace) override {
if (!row->empty() || subRows->empty()) {
cout << "read line " << static_cast<unsigned>(lineNo) << ": read error: got "
<< static_cast<unsigned>(row->size()) << "/0 main, " << static_cast<unsigned>(subRows->size())
@@ -512,7 +512,7 @@ int main() {
istringstream dummystr("#");
string errorDescription;
vector<string> row;
templates->readLineFromStream(&dummystr, __FILE__, false, &lineNo, &row, &errorDescription, NULL, NULL);
templates->readLineFromStream(&dummystr, __FILE__, false, &lineNo, &row, &errorDescription, false, NULL, NULL);
const DataField* fields = NULL;
for (unsigned int i = 0; i < sizeof(checks) / sizeof(checks[0]); i++) {
string check[5] = checks[i];
@@ -567,7 +567,7 @@ int main() {
}
if (isTemplate) {
lineNo = baseLine + i;
result = templates->readLineFromStream(&isstr, __FILE__, false, &lineNo, &row, &errorDescription, NULL, NULL);
result = templates->readLineFromStream(&isstr, __FILE__, false, &lineNo, &row, &errorDescription, false, NULL, NULL);
if (result != RESULT_OK) {
cout << "\"" << check[0] << "\": template read error: " << getResultCode(result) << ", "
<< errorDescription << endl;
@@ -579,7 +579,7 @@ int main() {
lineNo = 0;
dummystr.clear();
dummystr.str("#");
result = reader.readLineFromStream(&dummystr, __FILE__, false, &lineNo, &row, &errorDescription, NULL, NULL);
result = reader.readLineFromStream(&dummystr, __FILE__, false, &lineNo, &row, &errorDescription, false, NULL, NULL);
if (result != RESULT_OK) {
cout << "\"" << check[0] << "\": read header error: " << getResultCode(result) << ", " << errorDescription
<< endl;
@@ -587,7 +587,7 @@ int main() {
continue;
}
lineNo = baseLine + i;
result = reader.readLineFromStream(&isstr, "", false, &lineNo, &row, &errorDescription, NULL, NULL);
result = reader.readLineFromStream(&isstr, "", false, &lineNo, &row, &errorDescription, false, NULL, NULL);
fields = reader.m_fields;
if (failedCreate) {
if (result == RESULT_OK) {
+5 -5
View File
@@ -73,8 +73,8 @@ static unsigned int baseLine = 0;
class NoopReader : public FileReader {
public:
result_t addFromFile(const string& filename, unsigned int lineNo, vector<string>* row,
string* errorDescription) override {
result_t addFromFile(const string& filename, unsigned int lineNo, vector<string>* row, string* errorDescription,
bool replace) override {
return RESULT_OK;
}
};
@@ -98,7 +98,7 @@ class TestReader : public MappedFileReader {
return RESULT_ERR_EOF;
}
result_t addFromFile(const string& filename, unsigned int lineNo, map<string, string>* row,
vector< map<string, string> >* subRows, string* errorDescription) override {
vector< map<string, string> >* subRows, string* errorDescription, bool replace) override {
if (row->empty() || (m_expectedCols == 3) != subRows->empty()) {
cout << "read line " << static_cast<unsigned>(baseLine + lineNo) << ": read error: got "
<< static_cast<unsigned>(row->size()) << "/3 main, " << static_cast<unsigned>(subRows->size())
@@ -231,7 +231,7 @@ int main(int argc, char** argv) {
vector<string> row;
string errorDescription;
while (ifs.peek() != EOF) {
result_t result = reader.readLineFromStream(&ifs, "", true, &lineNo, &row, &errorDescription, &hash, &size);
result_t result = reader.readLineFromStream(&ifs, "", true, &lineNo, &row, &errorDescription, false, &hash, &size);
if (result != RESULT_OK) {
cout << " error " << getResultCode(result) << endl;
error = true;
@@ -271,7 +271,7 @@ int main(int argc, char** argv) {
subDefaults.resize(1);
subDefaults[0]["subcol 2"] = ";default of sub 0 subcol 2";
while (ifs.peek() != EOF) {
result_t result = reader2.readLineFromStream(&ifs, "", true, &lineNo, &row, &errorDescription, &hash, &size);
result_t result = reader2.readLineFromStream(&ifs, "", true, &lineNo, &row, &errorDescription, false, &hash, &size);
if (result != RESULT_OK) {
cout << " error " << getResultCode(result) << endl;
error = true;
+6 -6
View File
@@ -62,7 +62,7 @@ DataFieldTemplates* getTemplates(const string& filename) {
}
result_t loadDefinitionsFromConfigPath(FileReader* reader, const string& filename, bool verbose,
map<string, string>* defaults, string* errorDescription) {
map<string, string>* defaults, string* errorDescription, bool replace = false) {
time_t mtime = 0;
istream* stream = FileReader::openFile(filename, errorDescription, &mtime);
result_t result;
@@ -186,12 +186,12 @@ int main() {
istringstream dummystr("#");
string errorDescription;
vector<string> row;
templates->readLineFromStream(&dummystr, __FILE__, false, &lineNo, &row, &errorDescription, NULL, NULL);
templates->readLineFromStream(&dummystr, __FILE__, false, &lineNo, &row, &errorDescription, false, NULL, NULL);
lineNo = 0;
MessageMap* messages = new MessageMap("");
dummystr.clear();
dummystr.str("#");
messages->readLineFromStream(&dummystr, __FILE__, false, &lineNo, &row, &errorDescription, NULL, NULL);
messages->readLineFromStream(&dummystr, __FILE__, false, &lineNo, &row, &errorDescription, false, NULL, NULL);
vector< vector<string> > defaultsRows;
Message* message = NULL;
vector<MasterSymbolString*> mstrs;
@@ -222,7 +222,7 @@ int main() {
lineNo = baseLine + i;
cout << "line " << (lineNo+1) << " ";
if (isTemplate) {
result = templates->readLineFromStream(&isstr, __FILE__, false, &lineNo, &row, &errorDescription, NULL, NULL);
result = templates->readLineFromStream(&isstr, __FILE__, false, &lineNo, &row, &errorDescription, false, NULL, NULL);
if (result != RESULT_OK) {
cout << "\"" << check[0] << "\": template read error: " << getResultCode(result) << ", " << errorDescription
<< endl;
@@ -236,7 +236,7 @@ int main() {
}
if (isstr.peek() == '*') {
// store defaults or condition
result = messages->readLineFromStream(&isstr, __FILE__, false, &lineNo, &row, &errorDescription, NULL, NULL);
result = messages->readLineFromStream(&isstr, __FILE__, false, &lineNo, &row, &errorDescription, false, NULL, NULL);
if (result != RESULT_OK) {
cout << "\"" << check[0] << "\": default read error: " << getResultCode(result) << ", " << errorDescription << endl;
error = true;
@@ -318,7 +318,7 @@ int main() {
}
cout << "\"" << check[2] << "\": find OK" << endl;
} else {
result = messages->readLineFromStream(&isstr, __FILE__, false, &lineNo, &row, &errorDescription, NULL, NULL);
result = messages->readLineFromStream(&isstr, __FILE__, false, &lineNo, &row, &errorDescription, false, NULL, NULL);
if (failedCreate) {
if (result == RESULT_OK) {
cout << "\"" << check[0] << "\": failed create error: unexpectedly succeeded" << endl;