Chromium Code Reviews| Index: pkg/crypto/test/sha256_test.dart |
| diff --git a/pkg/crypto/test/sha256_test.dart b/pkg/crypto/test/sha256_test.dart |
| index 01bb4b8e7ad1f7eb24273bca16dc91e26165a11e..e8d1f31b4c773b4d8077bbbbdc64ab7459d0f84f 100644 |
| --- a/pkg/crypto/test/sha256_test.dart |
| +++ b/pkg/crypto/test/sha256_test.dart |
| @@ -5,21 +5,24 @@ |
| // Library tag to allow Dartium to run the tests. |
| library sha256_test; |
| -import "package:expect/expect.dart"; |
| +import "package:unittest/unittest.dart"; |
| import "package:crypto/crypto.dart"; |
| part 'sha256_long_test_vectors.dart'; |
| part 'sha256_short_test_vectors.dart'; |
| -List<int> createTestArr(int len) { |
| - var arr = new List<int>(len); |
| - for (var i = 0; i < len; i++) { |
| - arr[i] = i; |
| - } |
| - return arr; |
| + |
| +void main() { |
| + test('expected values', _testExpectedValues); |
| + test('invalid use', _testInvalidUse); |
| + test('repeated digest', _testRepeatedDigest); |
| + test('long inputs', |
| + () => _testStandardVectors(sha256_long_inputs, sha256_long_mds)); |
| + test('short inputs', |
| + () => _testStandardVectors(sha256_short_inputs, sha256_short_mds)); |
| } |
| -void test() { |
| +void _testExpectedValues() { |
| final expected_values = const [ |
|
Søren Gjesse
2014/02/18 07:41:38
expected_values -> expectedValues
kevmoo
2014/02/18 14:23:27
Done.
|
| 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', |
| '6e340b9cffb37a989ca544e6bb780a2c78901d3fb33738768511a30617afa01d', |
| @@ -280,38 +283,29 @@ void test() { |
| for (var i = 0; i < expected_values.length; i++) { |
| var hash = new SHA256(); |
| - hash.add(createTestArr(i)); |
| + hash.add(new List<int>.generate(i, (j) => j, growable: false)); |
| var d = hash.close(); |
| - Expect.equals(expected_values[i], CryptoUtils.bytesToHex(d), '$i'); |
| + expect(expected_values[i], CryptoUtils.bytesToHex(d), reason: '$i'); |
| } |
| } |
| -void testInvalidUse() { |
| +void _testInvalidUse() { |
| var sha = new SHA256(); |
| sha.close(); |
| - Expect.throws(() => sha.add([0]), (e) => e is StateError); |
| + expect(() => sha.add([0]), throwsStateError); |
| } |
| -void testRepeatedDigest() { |
| +void _testRepeatedDigest() { |
| var sha = new SHA256(); |
| var digest = sha.close(); |
| - Expect.listEquals(digest, sha.close()); |
| + expect(digest, sha.close()); |
| } |
| -void testStandardVectors(inputs, mds) { |
| +void _testStandardVectors(inputs, mds) { |
| for (var i = 0; i < inputs.length; i++) { |
| var hash = new SHA256(); |
| hash.add(inputs[i]); |
| var d = hash.close(); |
| - Expect.equals(mds[i], CryptoUtils.bytesToHex(d), '$i'); |
| + expect(mds[i], CryptoUtils.bytesToHex(d), reason: '$i'); |
| } |
| } |
| - |
| -void main() { |
| - test(); |
| - testInvalidUse(); |
| - testRepeatedDigest(); |
| - testStandardVectors(sha256_long_inputs, sha256_long_mds); |
| - testStandardVectors(sha256_short_inputs, sha256_short_mds); |
| -} |
| - |