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

Unified Diff: third_party/WebKit/Source/wtf/text/CStringTest.cpp

Issue 2240053002: Replace WTF_LOG() with NETWORK_DVLOG() or RESOURCE_LOADING_DVLOG(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sstream, EXPECT_STREQ Created 4 years, 4 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: third_party/WebKit/Source/wtf/text/CStringTest.cpp
diff --git a/third_party/WebKit/Source/wtf/text/CStringTest.cpp b/third_party/WebKit/Source/wtf/text/CStringTest.cpp
index 6e4956d1be3be43338383ade3766225816396261..0abb4601803b5f37d29c2e59fc194777658e541a 100644
--- a/third_party/WebKit/Source/wtf/text/CStringTest.cpp
+++ b/third_party/WebKit/Source/wtf/text/CStringTest.cpp
@@ -26,9 +26,22 @@
#include "wtf/text/CString.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include <sstream>
namespace WTF {
+namespace {
+
+CString printedString(const CString& string)
+{
+ std::ostringstream output;
+ output << string;
+ const std::string& result = output.str();
+ return CString(result.data(), result.length());
+}
+
+} // anonymous namespace
+
TEST(CStringTest, NullStringConstructor)
{
CString string;
@@ -197,4 +210,12 @@ TEST(CStringTest, Comparison)
EXPECT_TRUE(c != d);
}
+TEST(CStringTest, Printer)
+{
+ EXPECT_STREQ("<null>", printedString(CString()).data());
+ EXPECT_STREQ("\"abc\"", printedString("abc").data());
+ EXPECT_STREQ("\"\\t\\n\\r\\\"\\\\\"", printedString("\t\n\r\"\\").data());
+ EXPECT_STREQ("\"\\xFF\\x00\\x01xyz\"", printedString(CString("\xff\0\x01xyz", 6)).data());
+}
+
} // namespace WTF

Powered by Google App Engine
This is Rietveld 408576698