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

Unified Diff: base/strings/stringprintf_unittest.cc

Issue 632103004: Cleanup: Better constify some strings in base. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: lint Created 6 years, 2 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/strings/stringprintf_unittest.cc
diff --git a/base/strings/stringprintf_unittest.cc b/base/strings/stringprintf_unittest.cc
index a1bf2da42696504c7c780fea7eb6079f2c1ae512..5e48df83446fb056d771258eb97a6d73c65c55fe 100644
--- a/base/strings/stringprintf_unittest.cc
+++ b/base/strings/stringprintf_unittest.cc
@@ -106,7 +106,7 @@ TEST(StringPrintfTest, Grow) {
src[i] = 'A';
src[1025] = 0;
- const char* fmt = "%sB%sB%sB%sB%sB%sB%s";
+ const char fmt[] = "%sB%sB%sB%sB%sB%sB%s";
std::string out;
SStringPrintf(&out, fmt, src, src, src, src, src, src, src);
@@ -132,14 +132,15 @@ TEST(StringPrintfTest, StringAppendV) {
// Test the boundary condition for the size of the string_util's
// internal buffer.
TEST(StringPrintfTest, GrowBoundary) {
- const int string_util_buf_len = 1024;
+ const int kStringUtilBufLen = 1024;
// Our buffer should be one larger than the size of StringAppendVT's stack
// buffer.
- const int buf_len = string_util_buf_len + 1;
- char src[buf_len + 1]; // Need extra one for NULL-terminator.
- for (int i = 0; i < buf_len; ++i)
+ // And need extra one for NULL-terminator.
+ const int kBufLen = kStringUtilBufLen + 1 + 1;
+ char src[kBufLen];
+ for (int i = 0; i < kBufLen; ++i)
danakj 2014/10/07 17:13:54 this would be kBufLen - 1 then.
Lei Zhang 2014/10/17 21:19:38 Good catch, thanks.
src[i] = 'a';
- src[buf_len] = 0;
+ src[kBufLen] = 0;
danakj 2014/10/07 17:13:54 and kBufLen - 1 here. maybe we should leave it wit
Lei Zhang 2014/10/17 21:19:38 I'd like "buffer length" to actually be the length
std::string out;
SStringPrintf(&out, "%s", src);

Powered by Google App Engine
This is Rietveld 408576698