Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2945)

Unified Diff: base/string_number_conversions_unittest.cc

Issue 10699040: Relaunch Chrome in metro-mode with the help of a helper process. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/string_number_conversions_unittest.cc
diff --git a/base/string_number_conversions_unittest.cc b/base/string_number_conversions_unittest.cc
index 30b9b8c06ea416ee82820521f9b6f69ec5e16b1e..efc7bce88de9aaa5311dcc902b209ed1ce6acdb1 100644
--- a/base/string_number_conversions_unittest.cc
+++ b/base/string_number_conversions_unittest.cc
@@ -25,20 +25,20 @@ struct IntToStringTest {
TEST(StringNumberConversionsTest, IntToString) {
static const IntToStringTest<int> int_tests[] = {
- { 0, "0", "0" },
- { -1, "-1", "4294967295" },
- { std::numeric_limits<int>::max(), "2147483647", "2147483647" },
- { std::numeric_limits<int>::min(), "-2147483648", "2147483648" },
+ { 0, "0", "0" },
+ { -1, "-1", "4294967295" },
+ { std::numeric_limits<int>::max(), "2147483647", "2147483647" },
+ { std::numeric_limits<int>::min(), "-2147483648", "2147483648" },
};
static const IntToStringTest<int64> int64_tests[] = {
- { 0, "0", "0" },
- { -1, "-1", "18446744073709551615" },
- { std::numeric_limits<int64>::max(),
- "9223372036854775807",
- "9223372036854775807", },
- { std::numeric_limits<int64>::min(),
- "-9223372036854775808",
- "9223372036854775808" },
+ { 0, "0", "0" },
+ { -1, "-1", "18446744073709551615" },
+ { std::numeric_limits<int64>::max(),
+ "9223372036854775807",
+ "9223372036854775807", },
+ { std::numeric_limits<int64>::min(),
+ "-9223372036854775808",
+ "9223372036854775808" },
};
for (size_t i = 0; i < arraysize(int_tests); ++i) {
@@ -72,6 +72,25 @@ TEST(StringNumberConversionsTest, Uint64ToString) {
EXPECT_EQ(cases[i].output, Uint64ToString(cases[i].input));
}
+TEST(StringNumberConversionsTest, PointerToString) {
+ static const struct {
+ void* input;
+ const char* output;
+ } cases[] = {
+ {0, "0"},
+ {reinterpret_cast<void*>(42), "42"},
+ {reinterpret_cast<void*>(UINT_MAX), "4294967295"},
+ };
+
+ for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i)
+ EXPECT_EQ(std::string(cases[i].output), PointerToString(cases[i].input));
+
+ if (sizeof(void*) == sizeof(uint64)) {
+ EXPECT_EQ(std::string("18446744073709551615"),
+ PointerToString(reinterpret_cast<void*>(ULLONG_MAX)));
+ }
+}
+
TEST(StringNumberConversionsTest, StringToInt) {
static const struct {
std::string input;
@@ -200,6 +219,28 @@ TEST(StringNumberConversionsTest, StringToInt64) {
EXPECT_EQ(6, output);
}
+TEST(StringNumberConversionsTest, StringToPointer) {
+ static const struct {
+ const char* input;
+ void* output;
+ } cases[] = {
+ {"0", 0},
+ {"42", reinterpret_cast<void*>(42)},
+ {"4294967295", reinterpret_cast<void*>(UINT_MAX)},
+ };
+
+ void* value;
+ for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) {
+ EXPECT_TRUE(StringToPointer(cases[i].input, &value));
+ EXPECT_EQ(cases[i].output, value);
+ }
+
+ if (sizeof(void*) == sizeof(uint64)) {
+ EXPECT_TRUE(StringToPointer(std::string("18446744073709551615"), &value));
+ EXPECT_EQ(reinterpret_cast<void*>(ULLONG_MAX), value);
+ }
+}
+
TEST(StringNumberConversionsTest, HexStringToInt) {
static const struct {
std::string input;

Powered by Google App Engine
This is Rietveld 408576698