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

Side by Side Diff: tests/lib/src/crypto/sha1Test.dart

Issue 10174041: Increase test coverage for sha1 and sha256 by using standard test (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/lib/src/crypto/sha1_short_test_vectors.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 // TODO(ager): Replace with "dart:crypto" when ready. 5 // TODO(ager): Replace with "dart:crypto" when ready.
6 #import("../../../../lib/crypto/crypto.dart"); 6 #import("../../../../lib/crypto/crypto.dart");
7 7
8 #source('sha1_long_test_vectors.dart');
9 #source('sha1_short_test_vectors.dart');
10
8 List<int> createTestArr(int len) { 11 List<int> createTestArr(int len) {
9 var arr = new List<int>(len); 12 var arr = new List<int>(len);
10 for (var i = 0; i < len; i++) { 13 for (var i = 0; i < len; i++) {
11 arr[i] = i; 14 arr[i] = i;
12 } 15 }
13 return arr; 16 return arr;
14 } 17 }
15 18
16 String digestToString(List<int> digest) { 19 String digestToString(List<int> digest) {
17 var buf = new StringBuffer(); 20 var buf = new StringBuffer();
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 547
545 void testInvalidUse() { 548 void testInvalidUse() {
546 var sha = new SHA1(); 549 var sha = new SHA1();
547 sha.digest(); 550 sha.digest();
548 Expect.throws(sha.digest, 551 Expect.throws(sha.digest,
549 (e) => e is CryptoHashException); 552 (e) => e is CryptoHashException);
550 Expect.throws(() => sha.update([0]), 553 Expect.throws(() => sha.update([0]),
551 (e) => e is CryptoHashException); 554 (e) => e is CryptoHashException);
552 } 555 }
553 556
557 void testStandardVectors(inputs, mds) {
558 for (var i = 0; i < inputs.length; i++) {
559 var d = new SHA1().update(inputs[i]).digest();
560 Expect.equals(mds[i], digestToString(d), '$i');
561 }
562 }
563
554 void main() { 564 void main() {
555 test(); 565 test();
556 testInvalidUse(); 566 testInvalidUse();
567 testStandardVectors(sha1_long_inputs, sha1_long_mds);
568 testStandardVectors(sha1_short_inputs, sha1_short_mds);
557 } 569 }
OLDNEW
« no previous file with comments | « no previous file | tests/lib/src/crypto/sha1_short_test_vectors.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698