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

Unified Diff: tests/MD5Test.cpp

Issue 14265010: Make SkSHA1 and SkM5 use common SkDigestHash result type (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: add_SkHashDigest_wrapper_for_cityhash Created 7 years, 8 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: tests/MD5Test.cpp
===================================================================
--- tests/MD5Test.cpp (revision 8685)
+++ tests/MD5Test.cpp (working copy)
@@ -7,26 +7,22 @@
#include "Test.h"
#include "SkMD5.h"
-static bool digests_equal(const SkMD5::Digest& expectedDigest, const SkMD5::Digest& computedDigest) {
- for (size_t i = 0; i < SK_ARRAY_COUNT(expectedDigest.data); ++i) {
- if (expectedDigest.data[i] != computedDigest.data[i]) {
- return false;
- }
- }
- return true;
-}
+struct MD5Digest {
+ uint8_t data[16];
+};
-static void md5_test(const char* string, const SkMD5::Digest& expectedDigest, skiatest::Reporter* reporter) {
+static void md5_test(const char* string, const SkHashDigest& expectedDigest,
+ skiatest::Reporter* reporter) {
size_t len = strlen(string);
// All at once
{
SkMD5 context;
context.update(reinterpret_cast<const uint8_t*>(string), len);
- SkMD5::Digest digest;
- context.finish(digest);
+ SkHashDigest actualDigest;
+ context.finish(actualDigest);
- REPORTER_ASSERT(reporter, digests_equal(expectedDigest, digest));
+ REPORTER_ASSERT(reporter, expectedDigest.equals(actualDigest));
}
// One byte at a time.
@@ -37,16 +33,16 @@
for (; data < end; ++data) {
context.update(data, 1);
}
- SkMD5::Digest digest;
- context.finish(digest);
+ SkHashDigest actualDigest;
+ context.finish(actualDigest);
- REPORTER_ASSERT(reporter, digests_equal(expectedDigest, digest));
+ REPORTER_ASSERT(reporter, expectedDigest.equals(actualDigest));
}
}
static struct MD5Test {
const char* message;
- SkMD5::Digest digest;
+ const MD5Digest digestBytes;
} md5_tests[] = {
// Reference tests from RFC1321 Section A.5 ( http://www.ietf.org/rfc/rfc1321.txt )
{ "", {{ 0xd4, 0x1d, 0x8c, 0xd9, 0x8f, 0x00, 0xb2, 0x04, 0xe9, 0x80, 0x09, 0x98, 0xec, 0xf8, 0x42, 0x7e }} },
@@ -60,7 +56,9 @@
static void TestMD5(skiatest::Reporter* reporter) {
for (size_t i = 0; i < SK_ARRAY_COUNT(md5_tests); ++i) {
- md5_test(md5_tests[i].message, md5_tests[i].digest, reporter);
+ SkHashDigest expectedDigest(md5_tests[i].digestBytes.data,
+ sizeof(md5_tests[i].digestBytes.data));
+ md5_test(md5_tests[i].message, expectedDigest, reporter);
}
}
« tests/BitmapHasherTest.cpp ('K') | « tests/BitmapHasherTest.cpp ('k') | tests/SHA1Test.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698