char buf[2] = { 'X', 'X' };
// Negative buffer size should always result in an error.
- EXPECT_EQ(-1, SafeSNPrintf(buf, -1, ""));
+ EXPECT_EQ(-1, SafeSNPrintf(buf, static_cast<size_t>(-1), ""));
EXPECT_EQ('X', buf[0]);
EXPECT_EQ('X', buf[1]);
memcpy(buf, ref, sizeof(buf));
// A negative buffer size should always result in an error.
- EXPECT_EQ(-1, SafeSNPrintf(buf, -1, text));
+ EXPECT_EQ(-1, SafeSNPrintf(buf, static_cast<size_t>(-1), text));
EXPECT_TRUE(!memcmp(buf, ref, sizeof(buf)));
// Zero buffer size should always result in an error.
memcpy(buf, ref, sizeof(buf));
// A negative buffer size should always result in an error.
- EXPECT_EQ(-1, SafeSNPrintf(buf, -1, fmt, ' '));
+ EXPECT_EQ(-1, SafeSNPrintf(buf, static_cast<size_t>(-1), fmt, ' '));
EXPECT_TRUE(!memcmp(buf, ref, sizeof(buf)));
// Zero buffer size should always result in an error.
// The text that was generated by SafeSPrintf() should always match the
// equivalent text generated by sprintf(). Please note that the format
- // string for sprintf() is nor complicated, as it does not have the
+ // string for sprintf() is not complicated, as it does not have the
// benefit of getting type information from the C++ compiler.
//
// N.B.: It would be so much cleaner to use snprintf(). But unfortunately,
CHECK_LE(sz, sizeof(ref));
sprintf(ref, "A long string: %%d 00DEADBEEF %lld 0x%llX <NULL>",
static_cast<long long>(std::numeric_limits<intptr_t>::min()),
- (long long)PrintLongString);
+ static_cast<unsigned long long>(
+ reinterpret_cast<uintptr_t>(PrintLongString)));
ref[sz-1] = '\000';
#if defined(NDEBUG)