MCPcopy Create free account
hub / github.com/apache/singa / PrintCharAndCodeTo

Function PrintCharAndCodeTo

test/gtest/gtest-all.cc:9226–9248  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9224// UnsignedChar is the unsigned version of Char, which is the type of c.
9225template <typename UnsignedChar, typename Char>
9226void PrintCharAndCodeTo(Char c, ostream* os) {
9227 // First, print c as a literal in the most readable form we can find.
9228 *os << ((sizeof(c) > 1) ? "L'" : "'");
9229 const CharFormat format = PrintAsCharLiteralTo<UnsignedChar>(c, os);
9230 *os << "'";
9231
9232 // To aid user debugging, we also print c's code in decimal, unless
9233 // it's 0 (in which case c was printed as '\\0', making the code
9234 // obvious).
9235 if (c == 0)
9236 return;
9237 *os << " (" << static_cast<int>(c);
9238
9239 // For more convenience, we print c's code again in hexidecimal,
9240 // unless c was already printed in the form '\x##' or the code is in
9241 // [1, 9].
9242 if (format == kHexEscape || (1 <= c && c <= 9)) {
9243 // Do nothing.
9244 } else {
9245 *os << ", 0x" << String::FormatHexInt(static_cast<UnsignedChar>(c));
9246 }
9247 *os << ")";
9248}
9249
9250void PrintTo(unsigned char c, ::std::ostream* os) {
9251 PrintCharAndCodeTo<unsigned char>(c, os);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected