[go: nahoru, domu]

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

Unified Diff: base/string_util_unittest.cc
Issue 339059: Add compiler-specific "examine printf format" attributes to printfs. (Closed)
Patch Set: cleanups Created 11 years, 1 month 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_util_unittest.cc
diff --git a/base/string_util_unittest.cc b/base/string_util_unittest.cc
index d6910035a36f9785d7ce5cf7d7f2a557f306fa33..d47404e9c630a3a5b0ce94ec68576c445a223d27 100644
--- a/base/string_util_unittest.cc
+++ b/base/string_util_unittest.cc
@@ -827,9 +827,7 @@ TEST(StringUtilTest, VAList) {
VariableArgsFunc("%d %d %s %lf", 45, 92, "This is interesting", 9.21);
}
-TEST(StringUtilTest, StringPrintfEmptyFormat) {
- const char* empty = "";
- EXPECT_EQ("", StringPrintf(empty));
+TEST(StringUtilTest, StringPrintfEmpty) {
EXPECT_EQ("", StringPrintf("%s", ""));
}
@@ -838,16 +836,6 @@ TEST(StringUtilTest, StringPrintfMisc) {
EXPECT_EQ(L"123hello w", StringPrintf(L"%3d%2ls %1lc", 123, L"hello", 'w'));
}
-TEST(StringUtilTest, StringAppendfStringEmptyParam) {
- std::string value("Hello");
- StringAppendF(&value, "");
- EXPECT_EQ("Hello", value);
-
- std::wstring valuew(L"Hello");
- StringAppendF(&valuew, L"");
- EXPECT_EQ(L"Hello", valuew);
-}
-
TEST(StringUtilTest, StringAppendfEmptyString) {
std::string value("Hello");
StringAppendF(&value, "%s", "");
@@ -926,6 +914,23 @@ TEST(StringUtilTest, Grow) {
delete[] ref;
}
+// A helper for the StringAppendV test that follows.
+// Just forwards its args to StringAppendV.
+static void StringAppendVTestHelper(std::string* out,
Mark Mentovai 2009/11/18 20:55:27 Maybe mark this as PRINTF_FORMAT too.
+ const char* format,
+ ...) {
+ va_list ap;
+ va_start(ap, format);
+ StringAppendV(out, format, ap);
+ va_end(ap);
+}
+
+TEST(StringUtilTest, StringAppendV) {
+ std::string out;
+ StringAppendVTestHelper(&out, "%d foo %s", 1, "bar");
+ EXPECT_EQ("1 foo bar", out);
+}
+
// Test the boundary condition for the size of the string_util's
// internal buffer.
TEST(StringUtilTest, GrowBoundary) {
« no previous file with comments | « base/string_util.h ('k') | base/trace_event.cc » ('j') | chrome/app/chrome_dll_main.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698