| OLD | NEW |
| 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 // Library tag to allow dartium to run the test. | 5 // Library tag to allow dartium to run the test. |
| 6 library sha1_test; | 6 library sha1_test; |
| 7 | 7 |
| 8 import "package:crypto/crypto.dart"; | 8 import "package:crypto/crypto.dart"; |
| 9 import "package:test/test.dart"; | 9 import "package:test/test.dart"; |
| 10 | 10 |
| 11 part 'sha1_long_test_vectors.dart'; | 11 part 'sha1_long_test_vectors.dart'; |
| 12 part 'sha1_short_test_vectors.dart'; | 12 part 'sha1_short_test_vectors.dart'; |
| 13 | 13 |
| 14 | |
| 15 void main() { | 14 void main() { |
| 16 test('expected values', _testExpectedValues); | 15 test('expected values', _testExpectedValues); |
| 17 test('invalid use', _testInvalidUse); | 16 test('invalid use', _testInvalidUse); |
| 18 test('repeated digest', _testRepeatedDigest); | 17 test('repeated digest', _testRepeatedDigest); |
| 19 test('long inputs', () { | 18 test('long inputs', () { |
| 20 _testStandardVectors(sha1_long_inputs, sha1_long_mds); | 19 _testStandardVectors(sha1_long_inputs, sha1_long_mds); |
| 21 }); | 20 }); |
| 22 test('short inputs', () { | 21 test('short inputs', () { |
| 23 _testStandardVectors(sha1_short_inputs, sha1_short_mds); | 22 _testStandardVectors(sha1_short_inputs, sha1_short_mds); |
| 24 }); | 23 }); |
| (...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 } | 559 } |
| 561 | 560 |
| 562 void _testStandardVectors(inputs, mds) { | 561 void _testStandardVectors(inputs, mds) { |
| 563 for (var i = 0; i < inputs.length; i++) { | 562 for (var i = 0; i < inputs.length; i++) { |
| 564 var hash = new SHA1(); | 563 var hash = new SHA1(); |
| 565 hash.add(inputs[i]); | 564 hash.add(inputs[i]); |
| 566 var d = hash.close(); | 565 var d = hash.close(); |
| 567 expect(mds[i], CryptoUtils.bytesToHex(d), reason: '$i'); | 566 expect(mds[i], CryptoUtils.bytesToHex(d), reason: '$i'); |
| 568 } | 567 } |
| 569 } | 568 } |
| OLD | NEW |