added check for decode via loaded MessageMap
This commit is contained in:
@@ -47,11 +47,13 @@ int main()
|
||||
// field= name;[pos];type[;[divisor|values][;[unit][;[comment]]]]
|
||||
string checks[][5] = {
|
||||
// "message", "flags"
|
||||
{"c;;first;;;fe;0700;;x;;bda", "26.10.2014", "fffe0700042610061451", "00", "p"},
|
||||
{"u;;first;;;fe;0700;;x;;bda", "26.10.2014", "fffe0700042610061451", "00", "p"},
|
||||
{"w;;first;;;15;b509;0400;date;;bda", "26.10.2014", "ff15b5090604002610061445", "00", "m"},
|
||||
{"r;ehp;time;;;08;b509;0d2800;;;time", "15:00:17", "ff08b509030d2800ea", "0311000f00", "m"},
|
||||
{"r;ehp;date;;;08;b509;0d2900;;;hda:3", "23.11.2014", "ff08b509030d290071", "03170b0e5a", "m"},
|
||||
{"c;ehp;ActualEnvironmentPower;Energiebezug;;08;B509;29BA00;;s;IGN:2;;;;;s;power", "8", "1008b5090329ba00", "03ba0008", "p"},
|
||||
{"u;ehp;ActualEnvironmentPower;Energiebezug;;08;B509;29BA00;;s;IGN:2;;;;;s;power", "8", "1008b5090329ba00", "03ba0008", "pm"},
|
||||
{"","55.50;ok","1025b50903290000","050000780300",""},
|
||||
|
||||
};
|
||||
DataFieldTemplates* templates = new DataFieldTemplates();
|
||||
result_t result = templates->readFromFile("_types.csv");
|
||||
@@ -90,9 +92,16 @@ int main()
|
||||
delete deleteMessage;
|
||||
deleteMessage = NULL;
|
||||
}
|
||||
if (entries.size() == 0) {
|
||||
message = messages->find(mstr);
|
||||
if (message == NULL) {
|
||||
cout << " find error: NULL" << endl;
|
||||
continue;
|
||||
}
|
||||
cout << " find OK" << endl;
|
||||
} else {
|
||||
vector<string>::iterator it = entries.begin();
|
||||
result_t result = Message::create(it, entries.end(), NULL, templates, deleteMessage);
|
||||
|
||||
result = Message::create(it, entries.end(), NULL, templates, deleteMessage);
|
||||
if (failedCreate == true) {
|
||||
if (result == RESULT_OK)
|
||||
cout << "\"" << check[0] << "\": failed create error: unexpectedly succeeded" << endl;
|
||||
@@ -115,9 +124,8 @@ int main()
|
||||
continue;
|
||||
}
|
||||
cout << "\"" << check[0] << "\": create OK" << endl;
|
||||
|
||||
if (dontMap == false) {
|
||||
result = messages->add(deleteMessage);
|
||||
result_t result = messages->add(deleteMessage);
|
||||
if (result != RESULT_OK) {
|
||||
cout << "\"" << check[0] << "\": add error: "
|
||||
<< getResultCode(result) << endl;
|
||||
@@ -133,9 +141,23 @@ int main()
|
||||
}
|
||||
else
|
||||
message = deleteMessage;
|
||||
}
|
||||
istringstream input(inputStr);
|
||||
SymbolString writeMstr = SymbolString();
|
||||
result = message->prepare(0xff, writeMstr, input);
|
||||
if (message->isPassive() == true) {
|
||||
ostringstream output;
|
||||
result = message->decode(mstr, sstr, output);
|
||||
if (result != RESULT_OK) {
|
||||
cout << " \"" << inputStr << "\": decode error: "
|
||||
<< getResultCode(result) << endl;
|
||||
continue;
|
||||
}
|
||||
cout << " \"" << inputStr << "\": decode OK" << endl;
|
||||
|
||||
bool match = inputStr == output.str();
|
||||
verify(false, "decode", check[2] + "/" + check[3], match, inputStr, output.str());
|
||||
} else {
|
||||
result = message->prepareMaster(0xff, writeMstr, input);
|
||||
if (failedPrepare == true) {
|
||||
if (result == RESULT_OK)
|
||||
cout << " \"" << inputStr << "\": failed prepare error: unexpectedly succeeded" << endl;
|
||||
@@ -154,6 +176,7 @@ int main()
|
||||
bool match = writeMstr==mstr;
|
||||
verify(failedPrepareMatch, "prepare", inputStr, match, mstr.getDataStr(), writeMstr.getDataStr());
|
||||
}
|
||||
}
|
||||
|
||||
if (deleteMessage != NULL) {
|
||||
delete deleteMessage;
|
||||
|
||||
Reference in New Issue
Block a user