| 63 | } |
| 64 | |
| 65 | inline ::testing::AssertionResult assert_DataView(const char* a_expr, const char* b_expr, |
| 66 | const DataView& a, const DataView& b) |
| 67 | { |
| 68 | using namespace OpenDDS::DCPS; |
| 69 | if (a == b) { |
| 70 | return ::testing::AssertionSuccess(); |
| 71 | } |
| 72 | |
| 73 | std::string a_line; |
| 74 | // Use c_str so that it can cast to std::string on Safety Profile |
| 75 | std::stringstream a_strm(to_hex_dds_string(a.data, a.size, '\n', 8).c_str()); |
| 76 | std::string b_line; |
| 77 | std::stringstream b_strm(to_hex_dds_string(b.data, b.size, '\n', 8).c_str()); |
| 78 | std::stringstream result; |
| 79 | bool got_a = true; |
| 80 | bool got_b = true; |
| 81 | while (got_a || got_b) { |
| 82 | std::stringstream line; |
| 83 | line.width(16); |
| 84 | line << std::left; |
| 85 | if (got_a) { |
| 86 | if (std::getline(a_strm, a_line, '\n')) { |
| 87 | line << a_line; |
| 88 | } else { |
| 89 | got_a = false; |
| 90 | line << "(END OF LEFT)"; |
| 91 | } |
| 92 | } else { |
| 93 | line << ' '; |
| 94 | } |
| 95 | line << ' '; |
| 96 | line.width(16); |
| 97 | line << std::left; |
| 98 | if (got_b) { |
| 99 | if (std::getline(b_strm, b_line, '\n')) { |
| 100 | line << b_line; |
| 101 | } else { |
| 102 | got_b = false; |
| 103 | line << "(END OF RIGHT)"; |
| 104 | } |
| 105 | } else { |
| 106 | line << ' '; |
| 107 | } |
| 108 | if ((got_a || got_b) && a_line != b_line) { |
| 109 | line << " <- This line is different"; |
| 110 | } |
| 111 | const std::string line_str = line.str(); |
| 112 | if (line_str.find_first_not_of(" ") != std::string::npos) { |
| 113 | result << line_str << std::endl; |
| 114 | } |
| 115 | } |
| 116 | return ::testing::AssertionFailure() |
| 117 | << a_expr << " (size " << a.size << ") isn't the same as " |
| 118 | << b_expr << " (size " << b.size << ").\n" |
| 119 | << a_expr << " is on the left, " << b_expr << " is on the right:\n" |
| 120 | << result.str(); |
| 121 | } |
| 122 |
nothing calls this directly
no test coverage detected