Fix formatting of integer types smaller than int in FormatDec.

This commit is contained in:
Victor Zverovich
2014-02-20 07:04:54 -08:00
parent 2f423d8b46
commit 90d0c50eb3
2 changed files with 13 additions and 8 deletions
+5
View File
@@ -1454,6 +1454,11 @@ std::string FormatDec(T value) {
}
TEST(FormatIntTest, FormatDec) {
EXPECT_EQ("-42", FormatDec(static_cast<char>(-42)));
EXPECT_EQ("-42", FormatDec(static_cast<short>(-42)));
std::ostringstream os;
os << std::numeric_limits<unsigned short>::max();
EXPECT_EQ(os.str(), FormatDec(std::numeric_limits<unsigned short>::max()));
EXPECT_EQ("42", FormatDec(42));
EXPECT_EQ("-42", FormatDec(-42));
EXPECT_EQ("42", FormatDec(42l));