| OLD | NEW | 
|   1 /* |   1 /* | 
|   2  * Copyright 2013 Google Inc. |   2  * Copyright 2013 Google Inc. | 
|   3  * |   3  * | 
|   4  * Use of this source code is governed by a BSD-style license that can be |   4  * Use of this source code is governed by a BSD-style license that can be | 
|   5  * found in the LICENSE file. |   5  * found in the LICENSE file. | 
|   6  */ |   6  */ | 
 |   7  | 
|   7 #include "Test.h" |   8 #include "Test.h" | 
 |   9 #include "TestClassDef.h" | 
|   8 #include "SkSHA1.h" |  10 #include "SkSHA1.h" | 
|   9  |  11  | 
|  10 static bool digests_equal(const SkSHA1::Digest& expectedDigest, const SkSHA1::Di
    gest& computedDigest) { |  12 static bool digests_equal(const SkSHA1::Digest& expectedDigest, const SkSHA1::Di
    gest& computedDigest) { | 
|  11     for (size_t i = 0; i < SK_ARRAY_COUNT(expectedDigest.data); ++i) { |  13     for (size_t i = 0; i < SK_ARRAY_COUNT(expectedDigest.data); ++i) { | 
|  12         if (expectedDigest.data[i] != computedDigest.data[i]) { |  14         if (expectedDigest.data[i] != computedDigest.data[i]) { | 
|  13             return false; |  15             return false; | 
|  14         } |  16         } | 
|  15     } |  17     } | 
|  16     return true; |  18     return true; | 
|  17 } |  19 } | 
| (...skipping 20 matching lines...) Expand all  Loading... | 
|  38     SkSHA1 context; |  40     SkSHA1 context; | 
|  39     for (unsigned long int i = 0; i < test.repeatCount; ++i) { |  41     for (unsigned long int i = 0; i < test.repeatCount; ++i) { | 
|  40         context.update(reinterpret_cast<const uint8_t*>(test.message), len); |  42         context.update(reinterpret_cast<const uint8_t*>(test.message), len); | 
|  41     } |  43     } | 
|  42     SkSHA1::Digest digest; |  44     SkSHA1::Digest digest; | 
|  43     context.finish(digest); |  45     context.finish(digest); | 
|  44  |  46  | 
|  45     REPORTER_ASSERT(reporter, digests_equal(test.digest, digest)); |  47     REPORTER_ASSERT(reporter, digests_equal(test.digest, digest)); | 
|  46 } |  48 } | 
|  47  |  49  | 
|  48 static void TestSHA1(skiatest::Reporter* reporter) { |  50 DEF_TEST(SHA1, reporter) { | 
|  49     for (size_t i = 0; i < SK_ARRAY_COUNT(sha1_tests); ++i) { |  51     for (size_t i = 0; i < SK_ARRAY_COUNT(sha1_tests); ++i) { | 
|  50         sha1_test(sha1_tests[i], reporter); |  52         sha1_test(sha1_tests[i], reporter); | 
|  51     } |  53     } | 
|  52 } |  54 } | 
|  53  |  | 
|  54 #include "TestClassDef.h" |  | 
|  55 DEFINE_TESTCLASS("SHA1", SHA1TestClass, TestSHA1) |  | 
| OLD | NEW |