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

Function UniversalPrintCharArray

tests/gtest/gtest-all.cc:11401–11421  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11399GTEST_ATTRIBUTE_NO_SANITIZE_HWADDRESS_
11400GTEST_ATTRIBUTE_NO_SANITIZE_THREAD_
11401static void UniversalPrintCharArray(
11402 const CharType* begin, size_t len, ostream* os) {
11403 // The code
11404 // const char kFoo[] = "foo";
11405 // generates an array of 4, not 3, elements, with the last one being '\0'.
11406 //
11407 // Therefore when printing a char array, we don't print the last element if
11408 // it's '\0', such that the output matches the string literal as it's
11409 // written in the source code.
11410 if (len > 0 && begin[len - 1] == '\0') {
11411 PrintCharsAsStringTo(begin, len - 1, os);
11412 return;
11413 }
11414
11415 // If, however, the last element in the array is not '\0', e.g.
11416 // const char kFoo[] = { 'f', 'o', 'o' };
11417 // we must print the entire array. We also print a message to indicate
11418 // that the array is not NUL-terminated.
11419 PrintCharsAsStringTo(begin, len, os);
11420 *os << " (no terminating NUL)";
11421}
11422
11423// Prints a (const) char array of 'len' elements, starting at address 'begin'.
11424void UniversalPrintArray(const char* begin, size_t len, ostream* os) {

Callers 1

UniversalPrintArrayFunction · 0.85

Calls 1

PrintCharsAsStringToFunction · 0.85

Tested by

no test coverage detected