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

Unified Diff: util/stdlib/string_number_conversion_test.cc

Issue 807463004: win: avoid warnings in string_number_conversion_test.cc (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Created 6 years 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: util/stdlib/string_number_conversion_test.cc
diff --git a/util/stdlib/string_number_conversion_test.cc b/util/stdlib/string_number_conversion_test.cc
index ec0d44ae301dd267381923ce819a03649279d751..85db92ffc911efe138cd165958dc69a506c2c31f 100644
--- a/util/stdlib/string_number_conversion_test.cc
+++ b/util/stdlib/string_number_conversion_test.cc
@@ -53,7 +53,15 @@ TEST(StringNumberConversion, StringToInt) {
{"0x80000000", false, 0},
{"0xFFFFFFFF", false, 0},
{"-0x7fffffff", true, -2147483647},
+#if defined(COMPILER_MSVC)
Mark Mentovai 2014/12/16 14:17:47 build/build_config.h for this if it’s still necess
+#pragma warning(push)
+// Unary minus applied to unsigned type, result still unsigned.
+#pragma warning(disable: 4146)
+#endif
{"-0x80000000", true, -2147483648},
Mark Mentovai 2014/12/16 14:17:47 Would static_cast<>() also silence the warning? I
scottmg 2014/12/16 17:53:56 Cast inside i.e. -static_cast<int>(2147483648) avo
+#if defined(COMPILER_MSVC)
+#pragma warning(pop)
+#endif
{"-0x80000001", false, 0},
{"-0xffffffff", false, 0},
{"0x100000000", false, 0},
@@ -108,8 +116,10 @@ TEST(StringNumberConversion, StringToInt) {
}
}
- // Ensure that embedded NUL characters are treated as bad input.
- const char input[] = "6\0006";
+ // Ensure that embedded NUL characters are treated as bad input. The string
+ // is split to avoid MSVC warning:
+ // "decimal digit terminates octal escape sequence".
+ const char input[] = "6\000" "6";
base::StringPiece input_string(input, arraysize(input) - 1);
int output;
EXPECT_FALSE(StringToNumber(input_string, &output));
@@ -205,7 +215,7 @@ TEST(StringNumberConversion, StringToUnsignedInt) {
}
// Ensure that embedded NUL characters are treated as bad input.
Mark Mentovai 2014/12/16 14:17:47 The existing comment was duplicated from above, so
scottmg 2014/12/16 17:53:56 Done.
- const char input[] = "6\0006";
+ const char input[] = "6\000" "6";
base::StringPiece input_string(input, arraysize(input) - 1);
unsigned int output;
EXPECT_FALSE(StringToNumber(input_string, &output));
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698