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

Unified Diff: base/md5_unittest.cc

Issue 7466003: MD5Update function uses StringPiece instead of raw buffer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tfarina review Created 9 years, 5 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/md5_unittest.cc
diff --git a/base/md5_unittest.cc b/base/md5_unittest.cc
index c81ff123f023700df3ca23163be25f036dab090c..a20d819351c60c25553f85d903e63d8eac6ffdb5 100644
--- a/base/md5_unittest.cc
+++ b/base/md5_unittest.cc
@@ -120,7 +120,8 @@ TEST(MD5, ContextWithLongData) {
if (len > length - total)
len = length - total;
- MD5Update(&ctx, data.get() + total, len);
+ MD5Update(&ctx,
+ StringPiece(reinterpret_cast<char*>(data.get() + total), len));
total += len;
}
@@ -188,4 +189,19 @@ TEST(MD5, MD5StringTestSuite7) {
EXPECT_EQ(expected, actual);
}
+TEST(MD5, ContextWithStringData) {
+ MD5Context ctx;
+ MD5Init(&ctx);
+
+ MD5Update(&ctx, "abc");
+
+ MD5Digest digest;
+ MD5Final(&digest, &ctx);
+
+ std::string actual = MD5DigestToBase16(digest);
+ std::string expected = "900150983cd24fb0d6963f7d28e17f72";
+
+ EXPECT_EQ(expected, actual);
+}
+
} // namespace base
« base/md5.cc ('K') | « base/md5.cc ('k') | chrome/browser/bookmarks/bookmark_codec.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698