Commit bfc46a62 authored by Dorian Guillois's avatar Dorian Guillois
Browse files

Update ssh unit test.

parent 03bd0c5e
......@@ -43,6 +43,20 @@ using namespace com::centreon;
" \0" \
"Merethis is wonderful\n\0\0\0\0"
/**
* Replace null char by string "\0".
*
* @param[in, out] str The string to replace.
*
* @return The replace string.
*/
std::string& replace_null(std::string& str) {
size_t pos(0);
while ((pos = str.find('\0', pos)) != std::string::npos)
str.replace(pos++, 1, "\\0");
return (str);
}
/**
* Check that connector respond properly to version command.
*
......@@ -93,12 +107,11 @@ int main() {
try {
if (retval)
throw (basic_error() << "invalid return code: " << retval);
if (output.size() != (sizeof(RESULT) - 1))
if (output.size() != (sizeof(RESULT) - 1)
|| memcmp(output.c_str(), RESULT, sizeof(RESULT) - 1))
throw (basic_error()
<< "invalid output size: " << output.size()
<< ", output: " << output);
if (memcmp(output.c_str(), RESULT, sizeof(RESULT) - 1))
throw (basic_error() << "invalid output: " << output);
<< "invalid output: size=" << output.size()
<< ", output=" << replace_null(output));
}
catch (std::exception const& e) {
retval = 1;
......
......@@ -77,12 +77,11 @@ int main() {
try {
if (retval)
throw (basic_error() << "invalid return code: " << retval);
if (output.size() != (sizeof(RESULT) - 1))
if (output.size() != (sizeof(RESULT) - 1)
|| memcmp(output.c_str(), RESULT, sizeof(RESULT) - 1))
throw (basic_error()
<< "invalid output size: " << output.size()
<< ", output: " << output);
if (memcmp(output.c_str(), RESULT, sizeof(RESULT) - 1))
throw (basic_error() << "invalid output: " << output);
<< "invalid output: size=" << output.size()
<< ", output=" << output);
}
catch (std::exception const& e) {
retval = 1;
......
......@@ -93,12 +93,11 @@ int main() {
try {
if (retval)
throw (basic_error() << "invalid return code: " << retval);
if (output.size() != (sizeof(RESULT) - 1))
if (output.size() != (sizeof(RESULT) - 1)
|| memcmp(output.c_str(), RESULT, sizeof(RESULT) - 1))
throw (basic_error()
<< "invalid output size: " << output.size()
<< ", output: " << output);
if (memcmp(output.c_str(), RESULT, sizeof(RESULT) - 1))
throw (basic_error() << "invalid output: " << output);
<< "invalid output: size=" << output.size()
<< ", output=" << output);
}
catch (std::exception const& e) {
retval = 1;
......
......@@ -121,12 +121,11 @@ int main() {
try {
if (retval)
throw (basic_error() << "invalid return code: " << retval);
if (output.size() != (sizeof(RESULT) - 1))
if (output.size() != (sizeof(RESULT) - 1)
|| memcmp(output.c_str(), RESULT, sizeof(RESULT) - 1))
throw (basic_error()
<< "invalid output size: " << output.size()
<< ", output: " << output);
if (memcmp(output.c_str(), RESULT, sizeof(RESULT) - 1))
throw (basic_error() << "invalid output: " << output);
<< "invalid output: size=" << output.size()
<< ", output=" << output);
}
catch (std::exception const& e) {
retval = 1;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment