MCPcopy Create free account
hub / github.com/awslabs/aws-lambda-cpp / PrintCharAndCodeTo

Function PrintCharAndCodeTo

tests/gtest/gtest-all.cc:11324–11346  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11322// UnsignedChar is the unsigned version of Char, which is the type of c.
11323template <typename UnsignedChar, typename Char>
11324void PrintCharAndCodeTo(Char c, ostream* os) {
11325 // First, print c as a literal in the most readable form we can find.
11326 *os << ((sizeof(c) > 1) ? "L'" : "'");
11327 const CharFormat format = PrintAsCharLiteralTo<UnsignedChar>(c, os);
11328 *os << "'";
11329
11330 // To aid user debugging, we also print c's code in decimal, unless
11331 // it's 0 (in which case c was printed as '\\0', making the code
11332 // obvious).
11333 if (c == 0)
11334 return;
11335 *os << " (" << static_cast<int>(c);
11336
11337 // For more convenience, we print c's code again in hexadecimal,
11338 // unless c was already printed in the form '\x##' or the code is in
11339 // [1, 9].
11340 if (format == kHexEscape || (1 <= c && c <= 9)) {
11341 // Do nothing.
11342 } else {
11343 *os << ", 0x" << String::FormatHexInt(static_cast<int>(c));
11344 }
11345 *os << ")";
11346}
11347
11348void PrintTo(unsigned char c, ::std::ostream* os) {
11349 PrintCharAndCodeTo<unsigned char>(c, os);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected