added parameter to default skip last symbol in SymbolString::getDataStr (removes CRC from logging and hex result)

This commit is contained in:
john30
2015-03-07 15:36:17 +01:00
parent 97561ff87d
commit 353404e5b0
4 changed files with 20 additions and 17 deletions
+5 -4
View File
@@ -26,6 +26,7 @@ using namespace std;
void verify(bool expectFailMatch, string type, string input,
bool match, string expectStr, string gotStr)
{
match = match && expectStr == gotStr;
if (expectFailMatch) {
if (match)
cout << " failed " << type << " match >" << input
@@ -301,14 +302,14 @@ int main()
ostringstream output;
SymbolString writeMstr(false);
result = writeMstr.parseHex(mstr.getDataStr().substr(0, 10));
result = writeMstr.parseHex(mstr.getDataStr(true, false).substr(0, 10));
if (result != RESULT_OK) {
cout << " parse \"" << mstr.getDataStr().substr(0, 10) << "\" error: " << getResultCode(result) << endl;
cout << " parse \"" << mstr.getDataStr(true, false).substr(0, 10) << "\" error: " << getResultCode(result) << endl;
}
SymbolString writeSstr(false);
result = writeSstr.parseHex(sstr.getDataStr().substr(0, 2));
result = writeSstr.parseHex(sstr.getDataStr(true, false).substr(0, 2));
if (result != RESULT_OK) {
cout << " parse \"" << sstr.getDataStr().substr(0, 2) << "\" error: " << getResultCode(result) << endl;
cout << " parse \"" << sstr.getDataStr(true, false).substr(0, 2) << "\" error: " << getResultCode(result) << endl;
}
result = fields->read(pt_masterData, mstr, 0, output, false, verbose);
if (result >= RESULT_OK) {
+3 -3
View File
@@ -31,7 +31,7 @@ int main ()
if (result != RESULT_OK)
std::cout << "parse escaped error: " << getResultCode(result) << std::endl;
std::string gotStr = sstr.getDataStr(false), expectStr = "10feb5050427a90015a90177";
std::string gotStr = sstr.getDataStr(false, false), expectStr = "10feb5050427a90015a90177";
if (strcasecmp(gotStr.c_str(), expectStr.c_str()) == 0)
std::cout << "parse escaped OK" << std::endl;
@@ -51,7 +51,7 @@ int main ()
<< std::setfill('0') << static_cast<unsigned>(expectCrc)
<< std::endl;
gotStr = sstr.getDataStr(), expectStr = "10feb5050427a915aa77";
gotStr = sstr.getDataStr(true, false), expectStr = "10feb5050427a915aa77";
if (strcasecmp(gotStr.c_str(), expectStr.c_str()) == 0)
std::cout << "unescape OK" << std::endl;
@@ -64,7 +64,7 @@ int main ()
if (result != RESULT_OK)
std::cout << "parse unescaped error: " << getResultCode(result) << std::endl;
gotStr = sstr.getDataStr();
gotStr = sstr.getDataStr(true, false);
if (strcasecmp(gotStr.c_str(), expectStr.c_str()) == 0)
std::cout << "parse unescaped OK" << std::endl;