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

Unified Diff: tests/SHA1Test.cpp

Issue 14265010: Make SkSHA1 and SkM5 use common SkDigestHash result type (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: switch_to_MD5 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
« tests/BitmapHasherTest.cpp ('K') | « tests/MD5Test.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/SHA1Test.cpp
===================================================================
--- tests/SHA1Test.cpp (revision 8685)
+++ tests/SHA1Test.cpp (working copy)
@@ -7,19 +7,14 @@
#include "Test.h"
#include "SkSHA1.h"
-static bool digests_equal(const SkSHA1::Digest& expectedDigest, const SkSHA1::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 SHA1Digest {
+ uint8_t data[20];
+};
static struct SHA1Test {
const char* message;
const unsigned long int repeatCount;
- const SkSHA1::Digest digest;
+ const SHA1Digest digestBytes;
} sha1_tests[] = {
// Reference tests from RFC3174 Section 7.3 ( http://www.ietf.org/rfc/rfc3174.txt )
{ "abc", 1, {{ 0xA9, 0x99, 0x3E, 0x36, 0x47, 0x06, 0x81, 0x6A, 0xBA, 0x3E, 0x25, 0x71, 0x78, 0x50, 0xC2, 0x6C, 0x9C, 0xD0, 0xD8, 0x9D }} },
@@ -39,10 +34,11 @@
for (unsigned long int i = 0; i < test.repeatCount; ++i) {
context.update(reinterpret_cast<const uint8_t*>(test.message), len);
}
- SkSHA1::Digest digest;
- context.finish(digest);
+ SkHashDigest actualDigest;
+ context.finish(actualDigest);
- REPORTER_ASSERT(reporter, digests_equal(test.digest, digest));
+ SkHashDigest expectedDigest(test.digestBytes.data, sizeof(test.digestBytes.data));
+ REPORTER_ASSERT(reporter, expectedDigest.equals(actualDigest));
}
static void TestSHA1(skiatest::Reporter* reporter) {
« tests/BitmapHasherTest.cpp ('K') | « tests/MD5Test.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698