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 // This test is ripped from package:crypto to test the sha1 functionality copied | 5 // This test is ripped from package:crypto to test the sha1 functionality copied |
6 // into the compiler. | 6 // into the compiler. |
7 | 7 |
8 library sha1_test; | 8 library sha1_test; |
| 9 |
9 import 'package:compiler/src/hash/sha1.dart'; | 10 import 'package:compiler/src/hash/sha1.dart'; |
10 | 11 |
11 import "package:unittest/unittest.dart"; | 12 import "package:unittest/unittest.dart"; |
12 | 13 |
13 part 'sha1_long_test_vectors.dart'; | 14 part 'sha1_long_test_vectors.dart'; |
14 part 'sha1_short_test_vectors.dart'; | 15 part 'sha1_short_test_vectors.dart'; |
15 | 16 |
16 | |
17 void main() { | 17 void main() { |
18 test('expected values', _testExpectedValues); | 18 test('expected values', _testExpectedValues); |
19 test('invalid use', _testInvalidUse); | 19 test('invalid use', _testInvalidUse); |
20 test('repeated digest', _testRepeatedDigest); | 20 test('repeated digest', _testRepeatedDigest); |
21 test('long inputs', () { | 21 test('long inputs', () { |
22 _testStandardVectors(sha1_long_inputs, sha1_long_mds); | 22 _testStandardVectors(sha1_long_inputs, sha1_long_mds); |
23 }); | 23 }); |
24 test('short inputs', () { | 24 test('short inputs', () { |
25 _testStandardVectors(sha1_short_inputs, sha1_short_mds); | 25 _testStandardVectors(sha1_short_inputs, sha1_short_mds); |
26 }); | 26 }); |
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
570 } | 570 } |
571 | 571 |
572 void _testStandardVectors(inputs, mds) { | 572 void _testStandardVectors(inputs, mds) { |
573 for (var i = 0; i < inputs.length; i++) { | 573 for (var i = 0; i < inputs.length; i++) { |
574 var hash = new SHA1(); | 574 var hash = new SHA1(); |
575 hash.add(inputs[i]); | 575 hash.add(inputs[i]); |
576 var d = hash.close(); | 576 var d = hash.close(); |
577 expect(mds[i], bytesToHex(d), reason: '$i'); | 577 expect(mds[i], bytesToHex(d), reason: '$i'); |
578 } | 578 } |
579 } | 579 } |
OLD | NEW |