|
20 | 20 |
|
21 | 21 | #include "Matchers.h" |
22 | 22 |
|
| 23 | +#include <cctype>; |
23 | 24 | #include <gmock/gmock.h> |
24 | 25 |
|
25 | 26 |
|
@@ -48,15 +49,14 @@ bool MemoryCompare( |
48 | 49 | uint8_t expected = reinterpret_cast<const uint8_t*>(expected_data)[i]; |
49 | 50 |
|
50 | 51 | *listener |
51 | | - << "\n" << std::dec << i << ": 0x" << std::hex |
| 52 | + << "\n" << i << ": 0x" << std::hex |
52 | 53 | << static_cast<int>(expected) |
53 | 54 | << (expected == actual ? " == " : " != ") |
54 | 55 | << "0x" << static_cast<int>(actual) << " (" |
55 | | - << ((expected >= '!' && expected <= '~') ? |
56 | | - static_cast<char>(expected) : ' ') |
| 56 | + << (std::isprint(expected) ? static_cast<char>(expected) : ' ') |
57 | 57 | << (expected == actual ? " == " : " != ") |
58 | | - << (actual >= '!' && actual <= '~' ? static_cast<char>(actual) : ' ') |
59 | | - << ")"; |
| 58 | + << (std::isprint(actual) ? static_cast<char>(actual) : ' ') |
| 59 | + << ")" << std::dec; |
60 | 60 |
|
61 | 61 | } |
62 | 62 | listener->stream()->flags(ostream_flags); |
@@ -175,15 +175,14 @@ bool PayloadMatcher::MatchAndExplain( |
175 | 175 |
|
176 | 176 | if (listener->IsInterested()) { |
177 | 177 | *listener |
178 | | - << "\n" << std::dec << i << ": 0x" << std::hex |
| 178 | + << "\n" << i << ": 0x" << std::hex |
179 | 179 | << static_cast<int>(expected) |
180 | 180 | << (expected == actual ? " == " : " != ") |
181 | 181 | << "0x" << static_cast<int>(actual) << " (" |
182 | | - << ((expected >= '!' && expected <= '~') ? |
183 | | - static_cast<char>(expected) : ' ') |
| 182 | + << (std::isprint(expected) ? static_cast<char>(expected) : ' ') |
184 | 183 | << (expected == actual ? " == " : " != ") |
185 | | - << (actual >= '!' && actual <= '~' ? static_cast<char>(actual) : ' ') |
186 | | - << ")"; |
| 184 | + << (std::isprint(actual) ? static_cast<char>(actual) : ' ') |
| 185 | + << ")" << std::dec; |
187 | 186 | } |
188 | 187 |
|
189 | 188 | matched &= (expected == actual); |
|
0 commit comments